Skip to content

Commit 63973f8

Browse files
committed
Reduce complexity 3
1 parent c3a35d8 commit 63973f8

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

plugwise/helper.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,8 @@ def _get_measurement_data(self, dev_id: str) -> DeviceZoneData:
534534
if appliance.find("type").text in ACTUATOR_CLASSES:
535535
self._get_actuator_functionalities(appliance, device, data)
536536

537-
if dev_id == self.gateway_id and self.smile(ADAM):
538-
self._get_regulation_mode(appliance, data)
539-
self._get_gateway_mode(appliance, data)
540-
537+
self._get_regulation_mode(appliance, dev_id, data)
538+
self._get_gateway_mode(appliance, dev_id, data)
541539
self._get_gateway_outdoor_temp(dev_id, data)
542540

543541
if "c_heating_state" in data:
@@ -546,7 +544,8 @@ def _get_measurement_data(self, dev_id: str) -> DeviceZoneData:
546544
data.pop("c_heating_state")
547545
self._count -= 1
548546

549-
self._update_anna_cooling(dev_id, data)
547+
if self._is_thermostat and self.smile(ANNA):
548+
self._update_anna_cooling(dev_id, data)
550549

551550
def _power_data_from_location(self, loc_id: str) -> DeviceZoneData:
552551
"""Helper-function for smile.py: _get_device_zone_data().
@@ -692,22 +691,32 @@ def _get_actuator_functionalities(
692691
act_item = cast(ActuatorType, item)
693692
data[act_item] = temp_dict
694693

695-
def _get_regulation_mode(self, appliance: etree, data: DeviceZoneData) -> None:
694+
def _get_regulation_mode(
695+
self, appliance: etree, dev_id: str, data: DeviceZoneData
696+
) -> None:
696697
"""Helper-function for _get_measurement_data().
697698
698-
Collect the gateway regulation_mode.
699+
Adam: collect the gateway regulation_mode.
699700
"""
701+
if not (self.smile(ADAM) and dev_id == self.gateway_id):
702+
return
703+
700704
locator = "./actuator_functionalities/regulation_mode_control_functionality"
701705
if (search := appliance.find(locator)) is not None:
702706
data["select_regulation_mode"] = search.find("mode").text
703707
self._count += 1
704708
self._cooling_enabled = data["select_regulation_mode"] == "cooling"
705709

706-
def _get_gateway_mode(self, appliance: etree, data: DeviceZoneData) -> None:
710+
def _get_gateway_mode(
711+
self, appliance: etree, dev_id: str, data: DeviceZoneData
712+
) -> None:
707713
"""Helper-function for _get_measurement_data().
708714
709-
Collect the gateway mode.
715+
Adam: collect the gateway mode.
710716
"""
717+
if not (self.smile(ADAM) and dev_id == self.gateway_id):
718+
return
719+
711720
locator = "./actuator_functionalities/gateway_mode_control_functionality"
712721
if (search := appliance.find(locator)) is not None:
713722
data["select_gateway_mode"] = search.find("mode").text
@@ -746,7 +755,7 @@ def _process_c_heating_state(self, data: DeviceZoneData) -> None:
746755
"""
747756
# Adam or Anna + OnOff device
748757
if self._on_off_device:
749-
self._process_on_off_device_c_heating_state(self, data)
758+
self._process_on_off_device_c_heating_state(data)
750759

751760
# Anna + Elga: use central_heating_state to show heating_state
752761
if self._elga:
@@ -777,7 +786,7 @@ def _update_anna_cooling(self, dev_id: str, data: DeviceZoneData) -> None:
777786
778787
Support added for Techneco Elga and Thercon Loria/Thermastage.
779788
"""
780-
if self._is_thermostat and self.smile(ANNA) and dev_id == self._heater_id:
789+
if dev_id == self._heater_id:
781790
# Anna+Elga: base cooling_state on the elga-status-code
782791
if "elga_status_code" in data:
783792
if data["thermostat_supports_cooling"]:

0 commit comments

Comments
 (0)