1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 08:26:41 +01:00

Tibber, handle failed update

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
This commit is contained in:
Daniel Hjelseth Høyer
2026-03-24 08:29:28 +01:00
parent 56423f5712
commit 98d636274a

View File

@@ -292,27 +292,27 @@ class TibberPriceCoordinator(DataUpdateCoordinator[dict[str, TibberHomeData]]):
self.hass
)
active_homes = tibber_connection.get_homes(only_active=True)
today_start = dt_util.start_of_local_day()
today_end = today_start + timedelta(days=1)
def _has_prices_today(home: tibber.TibberHome) -> bool:
"""Return True if the home has any prices today."""
for start in home.price_total:
_LOGGER.error("Home %s has price %s", home.home_id, start)
start_dt = dt_util.as_local(datetime.fromisoformat(str(start)))
if today_start <= start_dt < today_end:
return True
return False
homes_to_update = [home for home in active_homes if not _has_prices_today(home)]
try:
await asyncio.gather(
tibber_connection.fetch_consumption_data_active_homes(),
tibber_connection.fetch_production_data_active_homes(),
)
today_start = dt_util.start_of_local_day()
today_end = today_start + timedelta(days=1)
def _has_prices_today(home: tibber.TibberHome) -> bool:
"""Return True if the home has any prices today."""
for start in home.price_total:
start_dt = dt_util.as_local(datetime.fromisoformat(str(start)))
if today_start <= start_dt < today_end:
return True
return False
homes_to_update = [
home for home in active_homes if not _has_prices_today(home)
]
if homes_to_update:
await asyncio.gather(
*(home.update_info_and_price_info() for home in homes_to_update)