Skip to content

Commit 3eca77d

Browse files
committed
Improve
1 parent fc32177 commit 3eca77d

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

plugwise/helper.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _all_locations(self) -> None:
260260

261261
self.loc_data[loc.loc_id] = {"name": loc.name}
262262

263-
def _energy_device_info_finder(self, appliance: etree, appl: Munch) -> Munch:
263+
def _energy_device_info_finder(self, appl: Munch, appliance: etree) -> Munch:
264264
"""Helper-function for _appliance_info_finder().
265265
266266
Collect energy device info (Smartmeter, Plug): firmware, model and vendor name.
@@ -338,15 +338,13 @@ def _appliance_info_finder(self, appl: Munch, appliance: etree) -> Munch:
338338

339339
# Collect heater_central device info
340340
if appl.pwclass == "heater_central":
341-
appl = self._appl_heater_central_info(appl, appliance)
342-
appl = self._appl_dhw_mode_info(appl, appliance)
341+
self._appl_heater_central_info(appl, appliance)
342+
self._appl_dhw_mode_info(appl, appliance)
343343

344344
return appl
345345

346346
# Collect info from power-related devices (Plug, Aqara Smart Plug)
347-
appl = self._energy_device_info_finder(appliance, appl)
348-
349-
return appl
347+
return self._energy_device_info_finder(appl, appliance)
350348

351349
def _appl_dhw_mode_info(self, appl: Munch, appliance: etree) -> Munch:
352350
"""Collect dhw control operation modes - Anna + Loria."""
@@ -371,7 +369,7 @@ def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
371369
appl.pwclass = "smartmeter"
372370
appl.zigbee_mac = None
373371
location = self._domain_objects.find(f'./location[@id="{loc_id}"]')
374-
appl = self._energy_device_info_finder(location, appl)
372+
appl = self._energy_device_info_finder(appl, location)
375373

376374
self.gw_devices[appl.dev_id] = {"dev_class": appl.pwclass}
377375
self._count += 1

plugwise/legacy/helper.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,16 @@ def _energy_device_info_finder(self, appliance: etree, appl: Munch) -> Munch:
156156

157157
def _appliance_info_finder(self, appliance: etree, appl: Munch) -> Munch:
158158
"""Collect device info (Smile/Stretch, Thermostats, OpenTherm/On-Off): firmware, model and vendor name."""
159+
match appl.pwclass:
159160
# Collect thermostat device info
160-
if appl.pwclass in THERMOSTAT_CLASSES:
161-
return self._appl_thermostat_info(appl, appliance, self._modules)
162-
161+
case _ as dev_class if dev_class in THERMOSTAT_CLASSES:
162+
return self._appl_thermostat_info(appl, appliance, self._modules)
163163
# Collect heater_central device info
164-
if appl.pwclass == "heater_central":
165-
return self._appl_heater_central_info(appl, appliance, self._appliances, self._modules)
166-
164+
case "heater_central":
165+
return self._appl_heater_central_info(appl, appliance, self._appliances, self._modules)
167166
# Collect info from Stretches
168-
appl = self._energy_device_info_finder(appliance, appl)
169-
170-
return appl
167+
case _:
168+
return self._energy_device_info_finder(appliance, appl)
171169

172170
def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
173171
"""Collect P1 DSMR Smartmeter info."""

0 commit comments

Comments
 (0)