Skip to content

Commit

Permalink
fix errors due to missing data
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjveraa committed Apr 16, 2024
1 parent 301405e commit 2c980a4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions custom_components/knmi/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ async def _async_update_data(self) -> dict[str, Any]:
)
# Do not throw an exception unless it's failed a few times to avoid excessive "unavailable" data
# in HASS
if self.failed_update_count > FAILED_UPDATES_ALLOWANCE:
_LOGGER.error(
"Update failed %s times, above limit of %s! - %s",
self.failed_update_count,
FAILED_UPDATES_ALLOWANCE,
exception,
)
raise UpdateFailed() from exception
if self.failed_update_count <= FAILED_UPDATES_ALLOWANCE:
# return the 'old' data on a failed update
_LOGGER.debug("Update failed, returning existing data")
return self.data

# Data update failed too many times, raise an error
_LOGGER.error(
"Update failed %s times, above limit of %s! - %s",
self.failed_update_count,
FAILED_UPDATES_ALLOWANCE,
exception,
)
raise UpdateFailed() from exception

def get_value(self, path: list[int | str], default=None) -> Any:
"""
Expand Down

0 comments on commit 2c980a4

Please sign in to comment.