Skip to content

Commit

Permalink
Add support for relative humidity as reported by Fritz!DECT400 with f…
Browse files Browse the repository at this point in the history
…irmware 05.10

Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER authored and hthiery committed Jan 3, 2021
1 parent e440db1 commit 569c29f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyfritzhome/devicetypes/fritzhomedevicetemperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class FritzhomeDeviceTemperature(FritzhomeDeviceBase):

offset = None
temperature = None
rel_humidity = None

def _update_from_node(self, node):
super()._update_from_node(node)
Expand Down Expand Up @@ -43,3 +44,11 @@ def _update_temperature_from_node(self, node):
)
except ValueError:
pass

humidity_element = node.find("humidity")
if humidity_element is not None:
try:
self.rel_humidity = self.get_node_value_as_int(humidity_element,
"rel_humidity")
except ValueError:
pass
32 changes: 32 additions & 0 deletions tests/responses/button/device_button_fritzdect440_fw_05_10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<devicelist version="1" fwversion="7.21">
<device identifier="12345 0000002" id="30" functionbitmask="1048864" fwversion="05.10" manufacturer="AVM" productname="FRITZ!DECT 440">
<present>1</present>
<txbusy>0</txbusy>
<name>Taster Wohnzimmer</name>
<battery>100</battery>
<batterylow>0</batterylow>
<temperature>
<celsius>215</celsius>
<offset>0</offset>
</temperature>
<humidity>
<rel_humidity>44</rel_humidity>
</humidity>
<button identifier="12345 0000002-1" id="5004">
<name>Taster Wohnzimmer: Oben rechts</name>
<lastpressedtimestamp>1609594202</lastpressedtimestamp>
</button>
<button identifier="12345 0000002-3" id="5005">
<name>Taster Wohnzimmer: Unten rechts</name>
<lastpressedtimestamp></lastpressedtimestamp>
</button>
<button identifier="12345 0000002-5" id="5006">
<name>Taster Wohnzimmer: Unten links</name>
<lastpressedtimestamp></lastpressedtimestamp>
</button>
<button identifier="12345 0000002-7" id="5007">
<name>Taster Wohnzimmer: Oben links</name>
<lastpressedtimestamp>1609603776</lastpressedtimestamp>
</button>
</device>
</devicelist>
10 changes: 10 additions & 0 deletions tests/test_fritzhomedevicebutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ def test_button_fritzdect440(self):
button = device.get_button_by_ain("12345 0000001-2")
eq_(button.name, "Taster Wohnzimmer: Unten rechts")
eq_(button.last_pressed, 1608557682)

def test_button_fritzdect440_humidity(self):
self.mock.side_effect = [
Helper.response("button/device_button_fritzdect440_fw_05_10"),
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12345 0000002")
assert_true(device.present)
eq_(device.rel_humidity, 44)

0 comments on commit 569c29f

Please sign in to comment.