Skip to content

Commit dec9074

Browse files
Merge pull request #630 from WillCodeForCats/handle-inverter-no-response
Continue on inverter no response when reading grid on/off
2 parents f26f30e + 3ad2a7a commit dec9074

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

custom_components/solaredge_modbus_multi/binary_sensor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ async def async_setup_entry(
3333
if hub.option_detect_extras and inverter.advanced_power_control:
3434
entities.append(AdvPowerControlEnabled(inverter, config_entry, coordinator))
3535

36-
if hub.option_detect_extras:
37-
entities.append(GridStatusOnOff(inverter, config_entry, coordinator))
36+
entities.append(GridStatusOnOff(inverter, config_entry, coordinator))
3837

3938
if entities:
4039
async_add_entities(entities)

custom_components/solaredge_modbus_multi/hub.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ async def connect(self) -> None:
460460
"""Connect to inverter."""
461461

462462
if self._client is None:
463-
_LOGGER.debug(f"New client object for {self._host}:{self._port}")
464463
_LOGGER.debug(
464+
"New AsyncModbusTcpClient: "
465465
f"reconnect_delay={self._mb_reconnect_delay} "
466466
f"reconnect_delay_max={self._mb_reconnect_delay_max} "
467467
f"retry_on_empty={self._mb_retry_on_empty} "
@@ -476,6 +476,7 @@ async def connect(self) -> None:
476476
timeout=self._mb_timeout,
477477
)
478478

479+
_LOGGER.debug((f"Connecting to {self._host}:{self._port} ..."))
479480
await self._client.connect()
480481

481482
def disconnect(self, clear_client: bool = False) -> None:
@@ -1323,7 +1324,14 @@ async def read_modbus_data(self) -> None:
13231324
)
13241325
self._grid_status = True
13251326

1326-
except ModbusIllegalAddress:
1327+
except (ModbusIllegalAddress, ModbusIOException) as e:
1328+
1329+
if (
1330+
type(e) is ModbusIOException
1331+
and "No response recieved after" not in e
1332+
):
1333+
raise
1334+
13271335
try:
13281336
del self.decoded_model["I_Grid_Status"]
13291337
except KeyError:
@@ -1332,9 +1340,12 @@ async def read_modbus_data(self) -> None:
13321340
self._grid_status = False
13331341

13341342
_LOGGER.debug(
1335-
(f"I{self.inverter_unit_id}: " "Grid On/Off NOT available")
1343+
(f"I{self.inverter_unit_id}: Grid On/Off NOT available: {e}")
13361344
)
13371345

1346+
if not self.hub.is_connected:
1347+
await self.hub.connect()
1348+
13381349
except ModbusIOError:
13391350
raise ModbusReadError(
13401351
f"No response from inverter ID {self.inverter_unit_id}"

custom_components/solaredge_modbus_multi/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"issue_tracker": "https://github.com/WillCodeForCats/solaredge-modbus-multi/issues",
1111
"loggers": ["custom_components.solaredge_modbus_multi"],
1212
"requirements": ["pymodbus>=3.6.6"],
13-
"version": "2.4.18"
13+
"version": "2.4.19-pre.2"
1414
}

0 commit comments

Comments
 (0)