Skip to content

Commit 57876ad

Browse files
committed
Break out extend_plug_device_class() function
1 parent 034d948 commit 57876ad

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

plugwise/helper.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@
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+
description = appliance.find("description").text
63+
if description is not None and (
64+
"ZigBee protocol" in description or "smart plug" in description
65+
):
66+
appl.pwclass = f"{appl.pwclass}_plug"
67+
68+
6069
def search_actuator_functionalities(
6170
appliance: etree.Element, actuator: str
6271
) -> etree.Element | None:
@@ -138,12 +147,7 @@ def _get_appliances(self) -> None:
138147
if appl.pwclass in THERMOSTAT_CLASSES and appl.location is None:
139148
continue
140149

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"
150+
extend_plug_device_class(appl, appliance)
147151

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

0 commit comments

Comments
 (0)