Skip to content

Commit d8f929c

Browse files
Ensure hub reconnects after optional failures
1 parent bee4428 commit d8f929c

File tree

1 file changed

+12
-3
lines changed
  • custom_components/solaredge_modbus_multi

1 file changed

+12
-3
lines changed

custom_components/solaredge_modbus_multi/hub.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,10 @@ async def read_modbus_data(self) -> None:
13431343
f"No response from inverter ID {self.inverter_unit_id}"
13441344
)
13451345

1346+
finally:
1347+
if not self.hub.is_connected:
1348+
await self.hub.connect()
1349+
13461350
""" Advanced Power Control """
13471351
""" Power Control Block """
13481352
if self.hub.option_detect_extras is True and (
@@ -1585,6 +1589,10 @@ async def read_modbus_data(self) -> None:
15851589
f"No response from inverter ID {self.inverter_unit_id}"
15861590
)
15871591

1592+
finally:
1593+
if not self.hub.is_connected:
1594+
await self.hub.connect()
1595+
15881596
""" Power Control Options: Site Limit Control """
15891597
if (
15901598
self.hub.option_site_limit_control is True
@@ -1701,9 +1709,6 @@ async def read_modbus_data(self) -> None:
17011709
self._grid_status = False
17021710
_LOGGER.debug((f"I{self.inverter_unit_id}: Grid On/Off NOT available"))
17031711

1704-
if not self.hub.is_connected:
1705-
await self.hub.connect()
1706-
17071712
except ModbusIOException as e:
17081713
_LOGGER.debug(
17091714
f"I{self.inverter_unit_id}: A modbus I/O exception occurred "
@@ -1716,6 +1721,10 @@ async def read_modbus_data(self) -> None:
17161721
f"No response from inverter ID {self.inverter_unit_id}"
17171722
)
17181723

1724+
finally:
1725+
if not self.hub.is_connected:
1726+
await self.hub.connect()
1727+
17191728
for name, value in iter(self.decoded_model.items()):
17201729
if isinstance(value, float):
17211730
display_value = float_to_hex(value)

0 commit comments

Comments
 (0)