From e35729d9b78f591b56a74f5d1c486a3c81325d22 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Fri, 21 Nov 2025 18:32:40 +0000 Subject: [PATCH] fix(coordinator): tomorrow sensors show unknown after 13:00 data fetch Synchronized coordinator._cached_price_data after API calls to ensure tomorrow data is available for sensor value calculations and lifecycle state detection. Impact: Tomorrow sensors now display values correctly after afternoon data fetch. Lifecycle sensor status remains stable without flickering between "searching_tomorrow" and other states. --- custom_components/tibber_prices/coordinator/core.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/tibber_prices/coordinator/core.py b/custom_components/tibber_prices/coordinator/core.py index df3155f..c56211a 100644 --- a/custom_components/tibber_prices/coordinator/core.py +++ b/custom_components/tibber_prices/coordinator/core.py @@ -556,10 +556,13 @@ class TibberPricesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): self._lifecycle_state = "fresh" # Data just fetched self._notify_lifecycle_change() # Push update: fresh data available - # CRITICAL: Sync cached_user_data after API call (for new integrations without cache) - # handle_main_entry_update() may have fetched user_data via update_user_data_if_needed() + # CRITICAL: Sync cached data after API call + # handle_main_entry_update() updates data_fetcher's cache, we need to sync: + # 1. cached_user_data (for new integrations, may be fetched via update_user_data_if_needed()) + # 2. cached_price_data (CRITICAL: contains tomorrow data, needed for _needs_tomorrow_data()) + # 3. _last_price_update (for lifecycle tracking: cache age, fresh state detection) self._cached_user_data = self._data_fetcher.cached_user_data - # Sync _last_price_update for lifecycle tracking + self._cached_price_data = self._data_fetcher.cached_price_data self._last_price_update = self._data_fetcher._last_price_update # noqa: SLF001 - Sync for lifecycle tracking return result # Subentries get data from main coordinator (no lifecycle tracking - they don't fetch)