Skip to content

Commit

Permalink
catch ValueError when there is no tsoll
Browse files Browse the repository at this point in the history
  • Loading branch information
mib1185 committed Jun 30, 2024
1 parent 91fc05c commit 7597ff7
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyfritzhome/devicetypes/fritzhomedevicethermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def _update_hkr_from_node(self, node):
except ValueError:
pass

self.target_temperature = self.get_temp_from_node(hkr_element, "tsoll")
try:
self.target_temperature = self.get_temp_from_node(hkr_element, "tsoll")
except ValueError:
self.target_temperature = None

self.eco_temperature = self.get_temp_from_node(hkr_element, "absenk")
self.comfort_temperature = self.get_temp_from_node(hkr_element, "komfort")

Expand Down
101 changes: 101 additions & 0 deletions tests/responses/groups/device_list_thermostat_without_tsoll.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0"?>
<devicelist version="1" fwversion="7.57">
<device identifier="09995 0523646" id="16" functionbitmask="320" fwversion="05.08" manufacturer="AVM" productname="FRITZ!DECT 301">
<present>1</present>
<txbusy>0</txbusy>
<name>Wohnzimmer Couch</name>
<battery>80</battery>
<batterylow>0</batterylow>
<temperature>
<celsius>220</celsius>
<offset>-10</offset>
</temperature>
<hkr>
<tist>44</tist>
<tsoll>43</tsoll>
<absenk>35</absenk>
<komfort>43</komfort>
<lock>0</lock>
<devicelock>0</devicelock>
<errorcode>0</errorcode>
<windowopenactiv>0</windowopenactiv>
<windowopenactiveendtime>0</windowopenactiveendtime>
<boostactive>0</boostactive>
<boostactiveendtime>0</boostactiveendtime>
<batterylow>0</batterylow>
<battery>80</battery>
<nextchange>
<endperiod>0</endperiod>
<tchange>43</tchange>
</nextchange>
<summeractive>0</summeractive>
<holidayactive>0</holidayactive>
<adaptiveHeatingActive>1</adaptiveHeatingActive>
<adaptiveHeatingRunning>0</adaptiveHeatingRunning>
</hkr>
</device>
<device identifier="09995 0517495" id="17" functionbitmask="320" fwversion="05.08" manufacturer="AVM" productname="FRITZ!DECT 301">
<present>1</present>
<txbusy>0</txbusy>
<name>Wohnzimmer Tisch</name>
<battery>80</battery>
<batterylow>0</batterylow>
<temperature>
<celsius>220</celsius>
<offset>-10</offset>
</temperature>
<hkr>
<tist>44</tist>
<tsoll>43</tsoll>
<absenk>35</absenk>
<komfort>43</komfort>
<lock>0</lock>
<devicelock>0</devicelock>
<errorcode>0</errorcode>
<windowopenactiv>0</windowopenactiv>
<windowopenactiveendtime>0</windowopenactiveendtime>
<boostactive>0</boostactive>
<boostactiveendtime>0</boostactiveendtime>
<batterylow>0</batterylow>
<battery>80</battery>
<nextchange>
<endperiod>0</endperiod>
<tchange>43</tchange>
</nextchange>
<summeractive>0</summeractive>
<holidayactive>0</holidayactive>
<adaptiveHeatingActive>1</adaptiveHeatingActive>
<adaptiveHeatingRunning>0</adaptiveHeatingRunning>
</hkr>
</device>
<group synchronized="1" identifier="grp303E4F-3F7D9BE07" id="900" functionbitmask="4160" fwversion="1.0" manufacturer="AVM" productname="">
<present>1</present>
<txbusy>0</txbusy>
<name>Wohnzimmer</name>
<hkr>
<tist/>
<tsoll/>
<absenk>35</absenk>
<komfort>43</komfort>
<lock>0</lock>
<devicelock>0</devicelock>
<errorcode>0</errorcode>
<windowopenactiv>0</windowopenactiv>
<windowopenactiveendtime>0</windowopenactiveendtime>
<boostactive>0</boostactive>
<boostactiveendtime>0</boostactiveendtime>
<nextchange>
<endperiod>0</endperiod>
<tchange>43</tchange>
</nextchange>
<summeractive>0</summeractive>
<holidayactive>0</holidayactive>
<adaptiveHeatingActive>1</adaptiveHeatingActive>
<adaptiveHeatingRunning>0</adaptiveHeatingRunning>
</hkr>
<groupinfo>
<masterdeviceid>0</masterdeviceid>
<members>16,17</members>
</groupinfo>
</group>
</devicelist>
34 changes: 34 additions & 0 deletions tests/test_fritzhomedevicethermostat_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def setup_method(self):
def test_device_alert_on(self):
self.mock.side_effect = [
Helper.response("groups/device_list_thermostat"),
Helper.response("groups/device_list_thermostat_without_tsoll"),
Helper.response("groups/device_list_thermostat"),
]

self.fritz.update_devices()
Expand All @@ -34,3 +36,35 @@ def test_device_alert_on(self):
assert group.window_open is False
assert group.boost_active_endtime == 0
assert group.window_open_endtime == 0
assert group.actual_temperature is None
assert group.target_temperature == 21.5

self.fritz.update_devices()
group = self.fritz.get_device_by_ain("grp303E4F-3F7D9BE07")
assert group.has_thermostat
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
assert group.actual_temperature is None
assert group.target_temperature is None

self.fritz.update_devices()
group = self.fritz.get_device_by_ain("grp303E4F-3F7D9BE07")
assert group.has_thermostat
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
assert group.actual_temperature is None
assert group.target_temperature == 21.5

0 comments on commit 7597ff7

Please sign in to comment.