Skip to content

Commit

Permalink
Fix mistake in _get_toggle_state()
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwew committed Nov 30, 2023
1 parent bc4f47d commit e3d95d1
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,15 +1555,12 @@ def _get_toggle_state(
Obtain the toggle state of a 'toggle' = switch.
"""
if xml.find("type").text == "heater_central":
locator = "./actuator_functionalities/toggle_functionality"
if found := xml.findall(locator):
for item in found:
if (toggle_type := item.find("type")) is not None:
if toggle_type.text == toggle:
data["switches"][name] = item.find("state").text == "on"
self._count += 1
# Remove the cooling_enabled binary_sensor when the corresponding switch is present
# Except for Elga
if toggle == "cooling_enabled" and not self._elga:
data["binary_sensors"].pop("cooling_enabled")
self._count -= 1
locator = f"./actuator_functionalities/toggle_functionality[type='{toggle}']/state"
if (state := xml.find(locator)) is not None:
data["switches"][name] = state.text == "on"
self._count += 1
# Remove the cooling_enabled binary_sensor when the corresponding switch is present
# Except for Elga
if toggle == "cooling_enabled" and not self._elga:
data["binary_sensors"].pop("cooling_enabled")
self._count -= 1

0 comments on commit e3d95d1

Please sign in to comment.