Skip to content

Commit

Permalink
Fix crash/errors when inverter is offline.
Browse files Browse the repository at this point in the history
  • Loading branch information
wimb0 authored Feb 24, 2025
1 parent 3bc256d commit 860ae4e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/saj_modbus/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ async def _async_update_data(self) -> dict:
self.read_modbus_realtime_data
)

self.close()
except ConnectionException:
except (BrokenPipeError, ConnectionResetError, ConnectionException) as conerr:
_LOGGER.error("Reading realtime data failed! Inverter is unreachable.")
_LOGGER.debug("Connection error: %s", conerr)
realtime_data["mpvmode"] = 0
realtime_data["mpvstatus"] = DEVICE_STATUSSES[0]
realtime_data["power"] = 0


self.close()
return {**self.inverter_data, **realtime_data}

def read_modbus_inverter_data(self) -> dict:
Expand Down

0 comments on commit 860ae4e

Please sign in to comment.