diff --git a/custom_components/tibber_prices/coordinator/core.py b/custom_components/tibber_prices/coordinator/core.py index 168e884..bfe40f4 100644 --- a/custom_components/tibber_prices/coordinator/core.py +++ b/custom_components/tibber_prices/coordinator/core.py @@ -739,7 +739,7 @@ class TibberPricesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): return {} return self._transform_data(self._cached_price_data) - def _get_threshold_percentages(self) -> dict[str, int]: + def _get_threshold_percentages(self) -> dict[str, int | float]: """Get threshold percentages from config options.""" return self._data_transformer.get_threshold_percentages() diff --git a/custom_components/tibber_prices/coordinator/data_transformation.py b/custom_components/tibber_prices/coordinator/data_transformation.py index 2c62347..ab59125 100644 --- a/custom_components/tibber_prices/coordinator/data_transformation.py +++ b/custom_components/tibber_prices/coordinator/data_transformation.py @@ -223,7 +223,8 @@ class TibberPricesDataTransformer: if not should_retransform and has_cache: self._log("debug", "Using cached transformed data (no transformation needed)") - return self._cached_transformed_data + # has_cache ensures _cached_transformed_data is not None + return self._cached_transformed_data # type: ignore[return-value] self._log("debug", "Transforming price data (enrichment + period calculation)") diff --git a/custom_components/tibber_prices/sensor/core.py b/custom_components/tibber_prices/sensor/core.py index 6dcfec6..5a6e4ba 100644 --- a/custom_components/tibber_prices/sensor/core.py +++ b/custom_components/tibber_prices/sensor/core.py @@ -221,7 +221,7 @@ class TibberPricesSensor(TibberPricesEntity, RestoreSensor): ) # Modify _state_info to add dynamic exclusion if self._state_info is None: - self._state_info = {} + self._state_info = {"unrecorded_attributes": frozenset()} current_unrecorded = self._state_info.get("unrecorded_attributes", frozenset()) # State shows median → exclude price_median from attributes # State shows mean → exclude price_mean from attributes