Skip to content

Commit 07ce6c1

Browse files
committed
Break out _appl_gateway_info() function
1 parent 1e31dc0 commit 07ce6c1

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

plugwise/helper.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -298,31 +298,7 @@ def _appliance_info_finder(self, appl: Munch, appliance: etree) -> Munch:
298298
"""Collect device info (Smile/Stretch, Thermostats, OpenTherm/On-Off): firmware, model and vendor name."""
299299
# Collect gateway device info
300300
if appl.pwclass == "gateway":
301-
self.gateway_id = appliance.attrib["id"]
302-
appl.firmware = self.smile_fw_version
303-
appl.hardware = self.smile_hw_version
304-
appl.mac = self.smile_mac_address
305-
appl.model = self.smile_model
306-
appl.name = self.smile_name
307-
appl.vendor_name = "Plugwise"
308-
309-
# Adam: collect the ZigBee MAC address of the Smile
310-
if self.smile(ADAM) and (
311-
(found := self._domain_objects.find(".//protocols/zig_bee_coordinator")) is not None
312-
):
313-
appl.zigbee_mac = found.find("mac_address").text
314-
315-
# Adam: collect regulation_modes and check for cooling, indicating cooling-mode is present
316-
self._appl_regulation_mode_info(appliance)
317-
318-
# Adam: collect the gateway_modes
319-
self._gw_allowed_modes = []
320-
locator = "./actuator_functionalities/gateway_mode_control_functionality[type='gateway_mode']/allowed_modes"
321-
if appliance.find(locator) is not None:
322-
# Limit the possible gateway-modes
323-
self._gw_allowed_modes = ["away", "full", "vacation"]
324-
325-
return appl
301+
return self._appl_gateway_info(appl, appliance)
326302

327303
# Collect thermostat device info
328304
if appl.pwclass in THERMOSTAT_CLASSES:
@@ -338,6 +314,34 @@ def _appliance_info_finder(self, appl: Munch, appliance: etree) -> Munch:
338314
# Collect info from power-related devices (Plug, Aqara Smart Plug)
339315
return self._energy_device_info_finder(appl, appliance)
340316

317+
def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
318+
"""Helper-function for _appliance_info_finder()."""
319+
self.gateway_id = appliance.attrib["id"]
320+
appl.firmware = self.smile_fw_version
321+
appl.hardware = self.smile_hw_version
322+
appl.mac = self.smile_mac_address
323+
appl.model = self.smile_model
324+
appl.name = self.smile_name
325+
appl.vendor_name = "Plugwise"
326+
327+
# Adam: collect the ZigBee MAC address of the Smile
328+
if self.smile(ADAM) and (
329+
(found := self._domain_objects.find(".//protocols/zig_bee_coordinator")) is not None
330+
):
331+
appl.zigbee_mac = found.find("mac_address").text
332+
333+
# Adam: collect regulation_modes and check for cooling, indicating cooling-mode is present
334+
self._appl_regulation_mode_info(appliance)
335+
336+
# Adam: collect the gateway_modes
337+
self._gw_allowed_modes = []
338+
locator = "./actuator_functionalities/gateway_mode_control_functionality[type='gateway_mode']/allowed_modes"
339+
if appliance.find(locator) is not None:
340+
# Limit the possible gateway-modes
341+
self._gw_allowed_modes = ["away", "full", "vacation"]
342+
343+
return appl
344+
341345
def _appl_regulation_mode_info(self, appliance: etree) -> None:
342346
"""Helper-function for _appliance_info_finder()."""
343347
reg_mode_list: list[str] = []

0 commit comments

Comments
 (0)