Skip to content

Commit

Permalink
fix optional battery group property
Browse files Browse the repository at this point in the history
  • Loading branch information
sebuer authored and hthiery committed Apr 16, 2024
1 parent 1834124 commit 0a2af26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pyfritzhome/devicetypes/fritzhomedevicethermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ def _update_hkr_from_node(self, node):
self.lock = self.get_node_value_as_int_as_bool(hkr_element, "lock")
self.error_code = self.get_node_value_as_int(hkr_element, "errorcode")
# keep battery values as fallback for Fritz!OS < 7.08
self.battery_low = self.get_node_value_as_int_as_bool(
hkr_element, "batterylow"
)
self.battery_level = int(self.get_node_value_as_int(hkr_element, "battery"))

if hkr_element.find("batterylow") is not None:
self.battery_low = self.get_node_value_as_int_as_bool(
hkr_element, "batterylow"
)
self.battery_level = int(self.get_node_value_as_int(hkr_element, "battery"))

self.window_open = self.get_node_value_as_int_as_bool(
hkr_element, "windowopenactiv"
)
Expand Down Expand Up @@ -103,13 +106,15 @@ def _update_hkr_from_node(self, node):
)
if self.boost_active_endtime < 0:
self.boost_active_endtime = 0

if hkr_element.find("adaptiveHeatingActive") is not None:
self.adaptive_heating_active = self.get_node_value_as_int_as_bool(
hkr_element, "adaptiveHeatingActive"
)
self.adaptive_heating_running = self.get_node_value_as_int_as_bool(
hkr_element, "adaptiveHeatingRunning"
)

except Exception:
pass

Expand Down
6 changes: 6 additions & 0 deletions tests/test_fritzhomedevicethermostat_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ def test_device_alert_on(self):
assert group.is_group
assert group.group_members == ["16", "17"]
assert group.supported_features == [FritzhomeDeviceFeatures.THERMOSTAT]
assert group.adaptive_heating_active is True
assert group.adaptive_heating_running is False
assert group.boost_active is False
assert group.window_open is False
assert group.boost_active_endtime == 0
assert group.window_open_endtime == 0

0 comments on commit 0a2af26

Please sign in to comment.