Skip to content

Commit

Permalink
Fixed intrerval checks
Browse files Browse the repository at this point in the history
  • Loading branch information
masaccio committed Sep 18, 2023
1 parent 2f82b59 commit 4341a0e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions custom_components/kingspan_watchman_sensit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,28 @@ def __init__(
self,
hass: HomeAssistant,
client: SENSiTApiClient,
update_interval=DEFAULT_UPDATE_INTERVAL,
update_interval: timedelta = DEFAULT_UPDATE_INTERVAL,
) -> None:
"""Initialize."""
self.api = client
self.platforms = []

super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=update_interval)
_LOGGER.debug("Update interval set to %s", update_interval)
super().__init__(
hass,
_LOGGER,
name=DOMAIN,
update_method=self.update,
update_interval=update_interval,
)

async def _async_update_data(self):
"""Update data via library."""
async def update(self):
"""Update data via API."""
try:
return await self.api.async_get_data()
except Exception as exception:
raise UpdateFailed() from exception
except Exception as e:
_LOGGER.debug("API update failed: %s", e)
raise UpdateFailed() from e


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down

0 comments on commit 4341a0e

Please sign in to comment.