Skip to content

Commit fb5cb22

Browse files
committed
Reduce complexity 2
1 parent d96ffce commit fb5cb22

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

plugwise/helper.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -744,29 +744,34 @@ def _process_c_heating_state(self, data: DeviceZoneData) -> None:
744744
745745
Process the central_heating_state value.
746746
"""
747+
# Adam or Anna + OnOff device
747748
if self._on_off_device:
748-
# Anna + OnOff heater: use central_heating_state to show heating_state
749-
# Solution for Core issue #81839
750-
if self.smile(ANNA):
751-
data["binary_sensors"]["heating_state"] = data["c_heating_state"]
752-
753-
# Adam + OnOff cooling: use central_heating_state to show heating/cooling_state
754-
if self.smile(ADAM):
755-
if "heating_state" not in data["binary_sensors"]:
756-
self._count += 1
757-
data["binary_sensors"]["heating_state"] = False
758-
if "cooling_state" not in data["binary_sensors"]:
759-
self._count += 1
760-
data["binary_sensors"]["cooling_state"] = False
761-
if self._cooling_enabled:
762-
data["binary_sensors"]["cooling_state"] = data["c_heating_state"]
763-
else:
764-
data["binary_sensors"]["heating_state"] = data["c_heating_state"]
749+
self._process_on_off_device_c_heating_state(self, data)
765750

766751
# Anna + Elga: use central_heating_state to show heating_state
767752
if self._elga:
768753
data["binary_sensors"]["heating_state"] = data["c_heating_state"]
769754

755+
def _process_on_off_device_c_heating_state(self, data: DeviceZoneData) -> None:
756+
""" Adam or Anna + OnOff device - use central_heating_state to show heating/cooling_state.
757+
758+
Solution for Core issue #81839.
759+
"""
760+
if self.smile(ANNA):
761+
data["binary_sensors"]["heating_state"] = data["c_heating_state"]
762+
763+
if self.smile(ADAM):
764+
if "heating_state" not in data["binary_sensors"]:
765+
self._count += 1
766+
data["binary_sensors"]["heating_state"] = False
767+
if "cooling_state" not in data["binary_sensors"]:
768+
self._count += 1
769+
data["binary_sensors"]["cooling_state"] = False
770+
if self._cooling_enabled:
771+
data["binary_sensors"]["cooling_state"] = data["c_heating_state"]
772+
else:
773+
data["binary_sensors"]["heating_state"] = data["c_heating_state"]
774+
770775
def _update_anna_cooling(self, dev_id: str, data: DeviceZoneData) -> None:
771776
"""Update the Anna heater_central device for cooling.
772777

0 commit comments

Comments
 (0)