Skip to content

Commit

Permalink
refactor: Do rediscovery only during TimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Jan 10, 2025
1 parent 036a5df commit 97783df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/solarman/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async def try_read_write(self, code, start, arg, message: str):
except Exception as e:
_LOGGER.debug(f"[{self.config.serial}] {message} failed, attempts left: {attempts_left}{'' if attempts_left > 0 else ', aborting.'} [{format_exception(e)}]")

if attempts_left == ACTION_ATTEMPTS - 2:
if isinstance(e, TimeoutError):
await self.endpoint.discover(True)
if not self.modbus.auto_reconnect:
await self.modbus.disconnect()
Expand Down

0 comments on commit 97783df

Please sign in to comment.