diff --git a/pyfibaro/fibaro_device.py b/pyfibaro/fibaro_device.py index 912e34f..18cb585 100644 --- a/pyfibaro/fibaro_device.py +++ b/pyfibaro/fibaro_device.py @@ -145,6 +145,28 @@ def has_armed(self) -> bool: """Returns true if the device has a unit property.""" return "armed" in self.properties + @property + def dead(self) -> bool: + """Returns the state if the device is reachable if supported, + otherwise False is returned. + """ + return _to_bool(self.properties.get("dead", False)) + + @property + def has_dead(self) -> bool: + """Returns true if the device has a dead property.""" + return "dead" in self.properties + + @property + def dead_reason(self) -> str | None: + """Returns the dead reason or None if not supported.""" + return self.properties.get("deadReason") + + @property + def has_dead_reason(self) -> bool: + """Returns true if the device has a deadReason property.""" + return "deadReason" in self.properties + @property def value(self) -> ValueModel: """Returns the value info.""" diff --git a/setup.cfg b/setup.cfg index e8bc92f..d3a7240 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pyfibaro -version = 0.6.9 +version = 0.7.0 description = Simple API to access fibaro home center from any Python 3 script. Designed for Home Assistant (but not only) long_description = file: README.md long_description_content_type = text/markdown diff --git a/tests/fixture/device-hc3.json b/tests/fixture/device-hc3.json index 400562e..e2d76f5 100644 --- a/tests/fixture/device-hc3.json +++ b/tests/fixture/device-hc3.json @@ -21,7 +21,8 @@ "autoConfig": 0, "configured": true, "date": "a", - "dead": false, + "dead": true, + "deadReason": "Connection problem", "deviceControlType": 1, "deviceIcon": 28, "deviceRole": "Other", diff --git a/tests/test_fibaro_device.py b/tests/test_fibaro_device.py index 90ab82f..caad6a2 100644 --- a/tests/test_fibaro_device.py +++ b/tests/test_fibaro_device.py @@ -80,6 +80,10 @@ def test_fibaro_device() -> None: assert devices[0].has_heating_thermostat_setpoint_future is False assert devices[0].heating_thermostat_setpoint_future == 0 assert devices[0].target_level == 0 + assert devices[0].has_dead is True + assert devices[0].dead is False + assert devices[0].has_dead_reason is False + assert devices[0].dead_reason is None assert isinstance(devices[0].actions, dict) assert isinstance(devices[0].properties, dict) diff --git a/tests/test_fibaro_device_hc3.py b/tests/test_fibaro_device_hc3.py index 158ce66..b324574 100644 --- a/tests/test_fibaro_device_hc3.py +++ b/tests/test_fibaro_device_hc3.py @@ -37,6 +37,10 @@ def test_fibaro_device() -> None: assert isinstance(devices[0].actions, dict) assert isinstance(devices[0].properties, dict) assert mock.call_count == 3 + assert devices[0].has_dead is True + assert devices[0].dead is True + assert devices[0].has_dead_reason is True + assert devices[0].dead_reason == "Connection problem" def test_fibaro_device_turn_on() -> None: