Skip to content

Commit

Permalink
More properties
Browse files Browse the repository at this point in the history
  • Loading branch information
WillCodeForCats committed Jul 9, 2023
1 parent 723e522 commit 69b5f19
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions custom_components/solaredge_modbus_multi/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __init__(
self._wr_address = None
self._wr_payload = None

self.initalized = False
self._initalized = False
self._online = True

self._client = AsyncModbusTcpClient(
Expand Down Expand Up @@ -382,7 +382,7 @@ async def async_refresh_modbus_data(self) -> bool:
raise HubInitFailed(f"Setup failed: {e}")

if not self.is_connected:
self._online = False
self.online = False
ir.async_create_issue(
self._hass,
DOMAIN,
Expand All @@ -399,7 +399,7 @@ async def async_refresh_modbus_data(self) -> bool:
else:
if not self.online:
ir.async_delete_issue(self._hass, DOMAIN, "check_configuration")
self._online = True
self.online = True

try:
for inverter in self.inverters:
Expand Down Expand Up @@ -431,6 +431,24 @@ async def async_refresh_modbus_data(self) -> bool:
def online(self):
return self._online

@online.setter
def online(self, value: bool) -> None:
if value is True:
self._online = True
else:
self._online = False

@property
def initalized(self):
return self._initalized

@initalized.setter
def initalized(self, value: bool) -> None:
if value is True:
self._initalized = True
else:
self._initalized = False

@property
def name(self):
"""Return the name of this hub."""
Expand Down Expand Up @@ -460,6 +478,13 @@ def option_site_limit_control(self) -> bool:
def keep_modbus_open(self) -> bool:
return self._keep_modbus_open

@keep_modbus_open.setter
def keep_modbus_open(self, value: bool) -> None:
if value is True:
self._keep_modbus_open = True
else:
self._keep_modbus_open = False

@property
def allow_battery_energy_reset(self) -> bool:
return self._allow_battery_energy_reset
Expand All @@ -472,15 +497,6 @@ def battery_rating_adjust(self) -> int:
def battery_energy_reset_cycles(self) -> int:
return self._battery_energy_reset_cycles

@keep_modbus_open.setter
def keep_modbus_open(self, value: bool) -> None:
if value is True:
self._keep_modbus_open = True
else:
self._keep_modbus_open = False

_LOGGER.debug(f"keep_modbus_open={self._keep_modbus_open}")

@property
def coordinator_timeout(self) -> int:
_LOGGER.debug(f"coordinator timeout is {self._coordinator_timeout}")
Expand All @@ -504,7 +520,7 @@ def is_connected(self) -> bool:

async def shutdown(self) -> None:
"""Shut down the hub."""
self._online = False
self.online = False
self.disconnect()
self._client = None

Expand Down

0 comments on commit 69b5f19

Please sign in to comment.