From 98d636274a580e653246d01735c0528d6a4386ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hjelseth=20H=C3=B8yer?= Date: Tue, 24 Mar 2026 08:29:28 +0100 Subject: [PATCH] Tibber, handle failed update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Hjelseth Høyer --- .../components/tibber/coordinator.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/tibber/coordinator.py b/homeassistant/components/tibber/coordinator.py index f48562a3f2f..45555b8c1fa 100644 --- a/homeassistant/components/tibber/coordinator.py +++ b/homeassistant/components/tibber/coordinator.py @@ -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)