Skip to content

Commit

Permalink
fix(collector): force the next update when the central unit is not av…
Browse files Browse the repository at this point in the history
…ailable
  • Loading branch information
palazzem committed Oct 6, 2023
1 parent 141322e commit a396d94
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions custom_components/econnect_metronet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import timedelta

import async_timeout
from elmo import query as q
from elmo.api.client import ElmoClient
from elmo.api.exceptions import InvalidToken
from elmo.systems import ELMO_E_CONNECT as E_CONNECT_DEFAULT
Expand Down Expand Up @@ -82,6 +83,14 @@ async def async_update_data():
# action blocks the thread for at most 15 seconds, or when
# something changes in the backend. POLLING_TIMEOUT ensures
# an upper bound regardless of the underlying implementation.
coordinator = hass.data[DOMAIN][entry.entry_id][KEY_COORDINATOR]
if not coordinator.last_update_success:
# Force a reset if the last update has failed, this forces an update
# until the device is available again.
device._lastIds = {
q.SECTORS: 0,
q.INPUTS: 0,
}
ids = await hass.async_add_executor_job(device._get_last_IDS)
_LOGGER.debug(f"Polling IDs registered in the device: {device._lastIds}")
_LOGGER.debug(f"Polling IDs expected in the update: {ids}")
Expand Down

0 comments on commit a396d94

Please sign in to comment.