Skip to content

Commit 06919ee

Browse files
committed
Simplify, improve readability
1 parent 23e6a40 commit 06919ee

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

plugwise/helper.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -852,39 +852,39 @@ def _appliance_measurements(
852852
):
853853
continue
854854

855-
meas_rn = measurement
856855
if new_name := getattr(attrs, ATTR_NAME, None):
857-
meas_rn = new_name
858-
match meas_rn:
856+
measurement = new_name
857+
858+
match measurement:
859859
# measurements with states "on" or "off" that need to be passed directly
860860
case "select_dhw_mode":
861861
data["select_dhw_mode"] = appl_p_loc.text
862-
case _ as meas_rn if meas_rn in BINARY_SENSORS:
863-
bs_key = cast(BinarySensorType, meas_rn)
862+
case _ as measurement if measurement in BINARY_SENSORS:
863+
bs_key = cast(BinarySensorType, measurement)
864864
bs_value = appl_p_loc.text in ["on", "true"]
865865
data["binary_sensors"][bs_key] = bs_value
866-
case _ as meas_rn if meas_rn in SENSORS:
867-
s_key = cast(SensorType, meas_rn)
866+
case _ as measurement if measurement in SENSORS:
867+
s_key = cast(SensorType, measurement)
868868
s_value = format_measure(
869869
appl_p_loc.text, getattr(attrs, ATTR_UNIT_OF_MEASUREMENT)
870870
)
871871
data["sensors"][s_key] = s_value
872872
# Anna: save cooling-related measurements for later use
873873
# Use the local outdoor temperature as reference for turning cooling on/off
874-
if meas_rn == "cooling_activation_outdoor_temperature":
874+
if measurement == "cooling_activation_outdoor_temperature":
875875
self._cooling_activation_outdoor_temp = data["sensors"][
876876
"cooling_activation_outdoor_temperature"
877877
]
878-
if meas_rn == "cooling_deactivation_threshold":
878+
if measurement == "cooling_deactivation_threshold":
879879
self._cooling_deactivation_threshold = data["sensors"][
880880
"cooling_deactivation_threshold"
881881
]
882-
if meas_rn == "outdoor_air_temperature":
882+
if measurement == "outdoor_air_temperature":
883883
self._outdoor_temp = data["sensors"][
884884
"outdoor_air_temperature"
885885
]
886-
case _ as meas_rn if meas_rn in SWITCHES:
887-
sw_key = cast(SwitchType, meas_rn)
886+
case _ as measurement if measurement in SWITCHES:
887+
sw_key = cast(SwitchType, measurement)
888888
sw_value = appl_p_loc.text in ["on", "true"]
889889
data["switches"][sw_key] = sw_value
890890
case "c_heating_state":

0 commit comments

Comments
 (0)