mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 05:13:40 +00:00
fix(types): resolve Pyright type errors
- coordinator/core.py: Fix return type for _get_threshold_percentages() - coordinator/data_transformation.py: Add type ignore for cached data return - sensor/core.py: Initialize _state_info with required unrecorded_attributes
This commit is contained in:
parent
4158e7b1fd
commit
49b8a018e7
3 changed files with 4 additions and 3 deletions
|
|
@ -739,7 +739,7 @@ class TibberPricesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
return {}
|
return {}
|
||||||
return self._transform_data(self._cached_price_data)
|
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."""
|
"""Get threshold percentages from config options."""
|
||||||
return self._data_transformer.get_threshold_percentages()
|
return self._data_transformer.get_threshold_percentages()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,8 @@ class TibberPricesDataTransformer:
|
||||||
|
|
||||||
if not should_retransform and has_cache:
|
if not should_retransform and has_cache:
|
||||||
self._log("debug", "Using cached transformed data (no transformation needed)")
|
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)")
|
self._log("debug", "Transforming price data (enrichment + period calculation)")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ class TibberPricesSensor(TibberPricesEntity, RestoreSensor):
|
||||||
)
|
)
|
||||||
# Modify _state_info to add dynamic exclusion
|
# Modify _state_info to add dynamic exclusion
|
||||||
if self._state_info is None:
|
if self._state_info is None:
|
||||||
self._state_info = {}
|
self._state_info = {"unrecorded_attributes": frozenset()}
|
||||||
current_unrecorded = self._state_info.get("unrecorded_attributes", frozenset())
|
current_unrecorded = self._state_info.get("unrecorded_attributes", frozenset())
|
||||||
# State shows median → exclude price_median from attributes
|
# State shows median → exclude price_median from attributes
|
||||||
# State shows mean → exclude price_mean from attributes
|
# State shows mean → exclude price_mean from attributes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue