Skip to content

Commit 745fc23

Browse files
Merge pull request #440 from WillCodeForCats/code-quality
Update exceptions from older pymodbus version
2 parents 985529a + 18e88db commit 745fc23

File tree

1 file changed

+6
-6
lines changed
  • custom_components/solaredge_modbus_multi

1 file changed

+6
-6
lines changed

custom_components/solaredge_modbus_multi/hub.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ async def _async_init_solaredge(self) -> None:
366366
self.disconnect()
367367
raise HubInitFailed(f"Connection failed: {e}")
368368

369-
except asyncio.TimeoutError as e:
369+
except ModbusIOException as e:
370370
self.disconnect()
371-
raise HubInitFailed(f"Modbus timeout: {e}")
371+
raise HubInitFailed(f"Modbus error: {e}")
372372

373373
self.initalized = True
374374

@@ -431,9 +431,9 @@ async def async_refresh_modbus_data(self) -> bool:
431431
self.disconnect()
432432
raise DataUpdateFailed(f"Connection failed: {e}")
433433

434-
except asyncio.TimeoutError as e:
434+
except ModbusIOException as e:
435435
self.disconnect()
436-
raise DataUpdateFailed(f"Modbus timeout: {e}")
436+
raise DataUpdateFailed(f"Modbus error: {e}")
437437

438438
if not self._keep_modbus_open:
439439
self.disconnect()
@@ -537,11 +537,11 @@ async def write_registers(self, unit: int, address: int, payload) -> None:
537537
self.has_write = None
538538
_LOGGER.debug(f"Finished with write {address}.")
539539

540-
except asyncio.TimeoutError:
540+
except ModbusIOException as e:
541541
self.disconnect()
542542

543543
raise HomeAssistantError(
544-
f"Timeout while sending command to inverter ID {self._wr_unit}."
544+
f"Error sending command to inverter ID {self._wr_unit}: {e}."
545545
)
546546

547547
except ConnectionException as e:

0 commit comments

Comments
 (0)