Skip to content

Commit 33e1e4d

Browse files
committed
Break out extend_plug_device_class() function
1 parent 034d948 commit 33e1e4d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

plugwise/helper.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@
5757
from packaging import version
5858

5959

60+
def extend_plug_device_class(appl: Munch, appliance: etree.Element) -> None:
61+
"""Extend device_class name of Plugs (Plugwise and Aqara) - Pw-Beta Issue #739."""
62+
63+
if (
64+
(search := appliance.find("description")) is not None
65+
and (description := search.text) is not None
66+
and ("ZigBee protocol" in description or "smart plug" in description)
67+
):
68+
appl.pwclass = f"{appl.pwclass}_plug"
69+
70+
6071
def search_actuator_functionalities(
6172
appliance: etree.Element, actuator: str
6273
) -> etree.Element | None:
@@ -138,12 +149,7 @@ def _get_appliances(self) -> None:
138149
if appl.pwclass in THERMOSTAT_CLASSES and appl.location is None:
139150
continue
140151

141-
# Extend device_class name of Plugs (Plugwise and Aqara) - Pw-Beta Issue #739
142-
description = appliance.find("description").text
143-
if description is not None and (
144-
"ZigBee protocol" in description or "smart plug" in description
145-
):
146-
appl.pwclass = f"{appl.pwclass}_plug"
152+
extend_plug_device_class(appl, appliance)
147153

148154
# Collect appliance info, skip orphaned/removed devices
149155
if not (appl := self._appliance_info_finder(appl, appliance)):

0 commit comments

Comments
 (0)