Tibber, fix spreading requests (#45533)

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
pull/45546/head
Daniel Hjelseth Høyer 2021-01-25 17:48:42 +01:00 committed by GitHub
parent 3de2c900f3
commit 094844f834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -102,14 +102,6 @@ class TibberSensorElPrice(TibberSensor):
async def async_update(self):
"""Get the latest data and updates the states."""
now = dt_util.now()
if (
self._tibber_home.current_price_total
and self._last_updated
and self._last_updated.hour == now.hour
and self._tibber_home.last_data_timestamp
):
return
if (
not self._tibber_home.last_data_timestamp
or (self._tibber_home.last_data_timestamp - now).total_seconds()
@ -119,6 +111,14 @@ class TibberSensorElPrice(TibberSensor):
_LOGGER.debug("Asking for new data")
await self._fetch_data()
elif (
self._tibber_home.current_price_total
and self._last_updated
and self._last_updated.hour == now.hour
and self._tibber_home.last_data_timestamp
):
return
res = self._tibber_home.current_price_data()
self._state, price_level, self._last_updated = res
self._device_state_attributes["price_level"] = price_level