From 094844f834780950f640289562566c2f5f886d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hjelseth=20H=C3=B8yer?= Date: Mon, 25 Jan 2021 17:48:42 +0100 Subject: [PATCH] Tibber, fix spreading requests (#45533) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Hjelseth Høyer --- homeassistant/components/tibber/sensor.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/tibber/sensor.py b/homeassistant/components/tibber/sensor.py index 1fb291bad5e..bb5ebe8011f 100644 --- a/homeassistant/components/tibber/sensor.py +++ b/homeassistant/components/tibber/sensor.py @@ -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