Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Dec 2, 2024
1 parent 5df9e50 commit ca543e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions custom_components/solis/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def __init__(self, portal_config: PortalConfig, hass: HomeAssistant) -> None:
self._retry_delay_seconds = 0
self._controllable: bool = False
self._controls: dict[str, dict[str, list[tuple]]] = {}
# self._active_times: dict[str, dict] = {}
if isinstance(portal_config, GinlongConfig):
self._api: BaseAPI = GinlongAPI(portal_config)
elif isinstance(portal_config, SoliscloudConfig):
Expand Down Expand Up @@ -133,6 +134,15 @@ def controls(self) -> dict:
def discovery_complete(self) -> bool:
return self._discovery_complete

# def set_active_times(self, inverter_sn, cid, index, times: tuple):
# if inverter_sn not in self._active_times:
# self._active_times[inverter_sn]={}

# if cid not in self._active_times[inverter_sn]:
# self._active_times[inverter_sn][cid]={}

# self._active_times[inverter_sn][cid][id]= times

async def _login(self) -> bool:
if not self._api.is_online:
if await self._api.login(async_get_clientsession(self._hass)):
Expand Down
4 changes: 4 additions & 0 deletions custom_components/solis/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f"Plant ID {plant_id} has controls:")
for inverter_sn in service.controls:
for cid, index, entity, button, initial_value in service.controls[inverter_sn]["time"]:
# service.set_active_times(inverter_sn, cid, index, (None, None)
entities.append(
SolisTimeEntity(
service,
Expand Down Expand Up @@ -80,6 +81,7 @@ def __init__(self, service: InverterService, config_name, inverter_sn, cid, time
self._icon = time_info.icon
self._splitter = time_info.splitter
self._index = index
# self._active_times = service.active_times[inverter_sn]
# Subscribe to the service with the cid as the index
if initial_value is not None:
self.do_update(initial_value, datetime.now())
Expand All @@ -105,6 +107,8 @@ def do_update(self, value, last_updated):
except:
_LOGGER.debug("Unable to convert {value} to time")

# Check if this time overlaps with any others

if time_value is None:
return False
elif self.hass and self._attr_native_value != time_value:
Expand Down

0 comments on commit ca543e7

Please sign in to comment.