Skip to content

Commit a07b83d

Browse files
committed
Breakout _get_appl_actuator_modes() function
1 parent c8dd4fe commit a07b83d

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

plugwise/helper.py

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ def _appliance_info_finder(self, appl: Munch, appliance: etree) -> Munch:
402402
case "heater_central":
403403
# Collect heater_central device info
404404
self._appl_heater_central_info(appl, appliance, False) # False means non-legacy device
405-
self._appl_dhw_mode_info(appl, appliance)
405+
self._dhw_allowed_modes = self._get_appl_actuator_modes(
406+
appliance, "domestic_hot_water_mode_control_functionality"
407+
)
406408
# Skip orphaned heater_central (Core Issue #104433)
407409
if appl.entity_id != self._heater_id:
408410
return Munch()
@@ -443,7 +445,9 @@ def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
443445
appl.zigbee_mac = found.find("mac_address").text
444446

445447
# Also, collect regulation_modes and check for cooling, indicating cooling-mode is present
446-
self._appl_regulation_mode_info(appliance)
448+
self._reg_allowed_modes = self._get_appl_actuator_modes(
449+
appliance, "regulation_mode_control_functionality"
450+
)
447451

448452
# Finally, collect the gateway_modes
449453
self._gw_allowed_modes = []
@@ -454,36 +458,18 @@ def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
454458

455459
return appl
456460

457-
def _appl_actuator_modes()
458-
459-
def _appl_regulation_mode_info(self, appliance: etree) -> None:
461+
def _get_appl_actuator_modes(self, appliance: etree, actuator_type: str) -> list[str]:
460462
"""Helper-function for _appliance_info_finder()."""
461-
reg_mode_list: list[str] = []
462-
if (search := search_actuator_functionalities(
463-
appliance, "regulation_mode_control_functionality"
464-
)) is not None:
463+
mode_list: list[str] = []
464+
if (search := search_actuator_functionalities(appliance, actuator_type)) is not None:
465465
if (modes := search.find("allowed_modes")) is not None:
466466
for mode in modes:
467-
reg_mode_list.append(mode.text)
467+
mode_list.append(mode.text)
468+
# Collect cooling_present state from the available regulation_modes
468469
if mode.text == "cooling":
469470
self._cooling_present = True
470-
self._reg_allowed_modes = reg_mode_list
471-
472-
def _appl_dhw_mode_info(self, appl: Munch, appliance: etree) -> Munch:
473-
"""Helper-function for _appliance_info_finder().
474471

475-
Collect dhw control operation modes - Anna + Loria.
476-
"""
477-
dhw_mode_list: list[str] = []
478-
if (search := search_actuator_functionalities(
479-
appliance, "domestic_hot_water_mode_control_functionality"
480-
)) is not None:
481-
if (modes := search.find("allowed_modes")) is not None:
482-
for mode in modes:
483-
dhw_mode_list.append(mode.text)
484-
self._dhw_allowed_modes = dhw_mode_list
485-
486-
return appl
472+
return mode_list
487473

488474
def _get_appliances_with_offset_functionality(self) -> list[str]:
489475
"""Helper-function collecting all appliance that have offset_functionality."""

0 commit comments

Comments
 (0)