From d29c54044de676cdb76cecffa50e6bd1efe85f77 Mon Sep 17 00:00:00 2001 From: Dave Foster <123640536+FozzieUK1@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:46:52 +0100 Subject: [PATCH] If inverter in alarm and variable read fails the api limit could be exhausted (#269) If an inverter is in alarm, and the api call to read the real time variables fails as a result, retrying every 1 minute would cause the integration to burn through api calls every minute - this state has been corrected to retry no more than every 5 minutes. --- custom_components/foxess/sensor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/custom_components/foxess/sensor.py b/custom_components/foxess/sensor.py index 70402d8..01913a1 100644 --- a/custom_components/foxess/sensor.py +++ b/custom_components/foxess/sensor.py @@ -188,6 +188,15 @@ async def async_update_data(): _LOGGER.debug("getReport False") else: _LOGGER.debug("getRaw False") + if statetest==2: + # The inverter is in alarm, don't check every minute + _LOGGER.debug(f" Inverter in alarm, slowing retry response for SN:{deviceSN}") + else: + # The get variables api call failed, leave it 5 minutes + _LOGGER.debug(f" Failed to get device variables, slowing retry response for SN:{deviceSN}") + allData["online"] = False + getError = False + TSlice = 25 # forces a retry on device detail in 5 minutes else: if statetest==3: # The inverter is off-line, no raw data polling, don't update entities