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) SCAN_INTERVAL = timedelta(minutes=1)
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
PARALLEL_UPDATES = 0 PARALLEL_UPDATES = 0
TWENTY_MINUTES = 20 * 60
RT_SENSORS_UNIQUE_ID_MIGRATION = { RT_SENSORS_UNIQUE_ID_MIGRATION = {
"accumulated_consumption_last_hour": "accumulated consumption current hour", "accumulated_consumption_last_hour": "accumulated consumption current hour",
@ -369,7 +369,7 @@ class TibberSensorElPrice(TibberSensor):
"""Initialize the sensor.""" """Initialize the sensor."""
super().__init__(tibber_home=tibber_home) super().__init__(tibber_home=tibber_home)
self._last_updated: datetime.datetime | None = None 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_available = False
self._attr_extra_state_attributes = { self._attr_extra_state_attributes = {
@ -397,7 +397,7 @@ class TibberSensorElPrice(TibberSensor):
if ( if (
not self._tibber_home.last_data_timestamp not self._tibber_home.last_data_timestamp
or (self._tibber_home.last_data_timestamp - now).total_seconds() 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 or not self.available
): ):
_LOGGER.debug("Asking for new data") _LOGGER.debug("Asking for new data")