From de59e8eb1633c25c80ded0353beb3afea29d7080 Mon Sep 17 00:00:00 2001 From: David Rapan Date: Fri, 27 Dec 2024 17:57:11 +0100 Subject: [PATCH] fix: Do rediscovery only once --- custom_components/solarman/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/solarman/api.py b/custom_components/solarman/api.py index 22aa31c..509410a 100644 --- a/custom_components/solarman/api.py +++ b/custom_components/solarman/api.py @@ -107,8 +107,8 @@ async def try_read_write(self, code, start, arg, message: str, incremental_wait: 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)}]") - await self.endpoint.discover(True) - + if attempts_left == ACTION_ATTEMPTS - 2: + await self.endpoint.discover(True) if not self.modbus.auto_reconnect: await self.modbus.disconnect() if not attempts_left > 0: