diff --git a/homeassistant/components/tibber/sensor.py b/homeassistant/components/tibber/sensor.py index adac836aca6..125dc8eae6f 100644 --- a/homeassistant/components/tibber/sensor.py +++ b/homeassistant/components/tibber/sensor.py @@ -50,7 +50,7 @@ ICON = "mdi:currency-usd" SCAN_INTERVAL = timedelta(minutes=1) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5) PARALLEL_UPDATES = 0 - +TWENTY_MINUTES = 20 * 60 RT_SENSORS_UNIQUE_ID_MIGRATION = { "accumulated_consumption_last_hour": "accumulated consumption current hour", @@ -369,7 +369,7 @@ class TibberSensorElPrice(TibberSensor): """Initialize the sensor.""" super().__init__(tibber_home=tibber_home) self._last_updated: datetime.datetime | None = None - self._spread_load_constant = randrange(5000) + self._spread_load_constant = randrange(TWENTY_MINUTES) self._attr_available = False self._attr_extra_state_attributes = { @@ -397,7 +397,7 @@ class TibberSensorElPrice(TibberSensor): if ( not self._tibber_home.last_data_timestamp or (self._tibber_home.last_data_timestamp - now).total_seconds() - < 5 * 3600 + self._spread_load_constant + < 11 * 3600 + self._spread_load_constant or not self.available ): _LOGGER.debug("Asking for new data")