Skip to content

Commit cd693e6

Browse files
committed
Use match-case
1 parent 07ce6c1 commit cd693e6

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

plugwise/helper.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -296,23 +296,21 @@ def _energy_device_info_finder(self, appl: Munch, appliance: etree) -> Munch:
296296

297297
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."""
299-
# Collect gateway device info
300-
if appl.pwclass == "gateway":
301-
return self._appl_gateway_info(appl, appliance)
302-
303-
# Collect thermostat device info
304-
if appl.pwclass in THERMOSTAT_CLASSES:
305-
return self._appl_thermostat_info(appl, appliance)
306-
307-
# Collect heater_central device info
308-
if appl.pwclass == "heater_central":
309-
self._appl_heater_central_info(appl, appliance)
310-
self._appl_dhw_mode_info(appl, appliance)
311-
312-
return appl
313-
314-
# Collect info from power-related devices (Plug, Aqara Smart Plug)
315-
return self._energy_device_info_finder(appl, appliance)
299+
match appl.pwclass:
300+
case "gateway":
301+
# Collect gateway device info
302+
return self._appl_gateway_info(appl, appliance)
303+
case _ as dev_class if dev_class in THERMOSTAT_CLASSES:
304+
# Collect thermostat device info
305+
return self._appl_thermostat_info(appl, appliance)
306+
case "heater_central":
307+
# Collect heater_central device info
308+
self._appl_heater_central_info(appl, appliance)
309+
self._appl_dhw_mode_info(appl, appliance)
310+
return appl
311+
case _:
312+
# Collect info from power-related devices (Plug, Aqara Smart Plug)
313+
return self._energy_device_info_finder(appl, appliance)
316314

317315
def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
318316
"""Helper-function for _appliance_info_finder()."""

0 commit comments

Comments
 (0)