Tibber, fix spreading requests (#45533)
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>pull/45546/head
parent
3de2c900f3
commit
094844f834
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue