Change Tibber request spread (#129276)

This commit is contained in:
Daniel Hjelseth Høyer 2024-10-29 13:12:07 +01:00 committed by GitHub
parent da11a72b4c
commit 7929895b11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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")