diff --git a/plugwise/constants.py b/plugwise/constants.py index 90f20b11d2..752d2600d9 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -333,6 +333,13 @@ "heater_electric", ) +SpecialType = Literal[ + "c_heating_state", + "thermostat_supports_cooling", +] + +SPECIALS: Final[tuple[str, ...]] = get_args(SpecialType) + SPECIAL_FORMAT: Final[tuple[str, ...]] = (ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS) SwitchType = Literal[ @@ -511,6 +518,7 @@ class DeviceData(TypedDict, total=False): domestic_hot_water_setpoint: float elga_status_code: int c_heating_state: bool + thermostat_supports_cooling: bool # Device availability available: bool | None diff --git a/plugwise/helper.py b/plugwise/helper.py index 28c0cd3584..4b1e06eb07 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -46,6 +46,7 @@ POWER_WATT, SENSORS, SPECIAL_PLUG_TYPES, + SPECIALS, SWITCH_GROUP_TYPES, SWITCHES, TEMP_CELSIUS, @@ -61,6 +62,7 @@ GatewayData, ModelData, SensorType, + SpecialType, SwitchType, ThermoLoc, ToggleNameType, @@ -860,11 +862,10 @@ def _appliance_measurements( sw_key = cast(SwitchType, measurement) sw_value = appl_p_loc.text in ["on", "true"] data["switches"][sw_key] = sw_value - case _ as measurement if measurement in ( - "c_heating_state", "thermostat_supports_cooling" - ): - value = appl_p_loc.text in ["on", "true"] - data[measurement] = value + case _ as measurement if measurement in SPECIALS: + sp_key = cast(SpecialType, measurement) + sp_value = appl_p_loc.text in ["on", "true"] + data[sp_key] = sp_value case "elga_status_code": data["elga_status_code"] = int(appl_p_loc.text)