Skip to content

Commit

Permalink
Add constants, update typing, implement
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwew committed Dec 27, 2023
1 parent cb8219c commit 65c0c9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions plugwise/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
POWER_WATT,
SENSORS,
SPECIAL_PLUG_TYPES,
SPECIALS,
SWITCH_GROUP_TYPES,
SWITCHES,
TEMP_CELSIUS,
Expand All @@ -61,6 +62,7 @@
GatewayData,
ModelData,
SensorType,
SpecialType,
SwitchType,
ThermoLoc,
ToggleNameType,
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 65c0c9f

Please sign in to comment.