Skip to content

Commit 9d67f93

Browse files
committed
Solve complexity
1 parent 49d3017 commit 9d67f93

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

plugwise/helper.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,7 @@ def _appliance_measurements(
471471
case "elga_status_code":
472472
data["elga_status_code"] = int(appl_p_loc.text)
473473
case "select_dhw_mode":
474-
if self._dhw_allowed_modes and "select_dhw_mode" not in data:
475-
data["select_dhw_mode"] = appl_p_loc.text
476-
if old_measurement == "domestic_hot_water_comfort_mode":
477-
data["select_dhw_mode"] = (
478-
"comfort" if appl_p_loc.text == "on" else "off"
479-
)
474+
self._select_dhw_mode(appl_p_loc.text, data, old_measurement)
480475

481476
common_match_cases(measurement, attrs, appl_p_loc, data)
482477

@@ -489,6 +484,15 @@ def _appliance_measurements(
489484

490485
self._count = count_data_items(self._count, data)
491486

487+
def _select_dhw_mode(self, text: str, data: GwEntityData, measurement: str) -> None:
488+
"""Set the selected dhw mode."""
489+
if self._dhw_allowed_modes and "select_dhw_mode" not in data:
490+
data["select_dhw_mode"] = text
491+
if measurement == "domestic_hot_water_comfort_mode":
492+
data["select_dhw_mode"] = (
493+
"comfort" if text == "on" else "off"
494+
)
495+
492496
def _get_toggle_state(
493497
self,
494498
xml: etree.Element,

0 commit comments

Comments
 (0)