Add bypassed custom attribute to NX584ZoneSensor (#71767)

This commit is contained in:
Christian Rodriguez 2022-06-22 20:59:59 -03:00 committed by GitHub
parent 3cd18ba38f
commit 3ce5b05aa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -116,7 +116,10 @@ class NX584ZoneSensor(BinarySensorEntity):
@property
def extra_state_attributes(self):
"""Return the state attributes."""
return {"zone_number": self._zone["number"]}
return {
"zone_number": self._zone["number"],
"bypassed": self._zone.get("bypassed", False),
}
class NX584Watcher(threading.Thread):

View file

@ -153,11 +153,28 @@ def test_nx584_zone_sensor_normal():
assert not sensor.should_poll
assert sensor.is_on
assert sensor.extra_state_attributes["zone_number"] == 1
assert not sensor.extra_state_attributes["bypassed"]
zone["state"] = False
assert not sensor.is_on
def test_nx584_zone_sensor_bypassed():
"""Test for the NX584 zone sensor."""
zone = {"number": 1, "name": "foo", "state": True, "bypassed": True}
sensor = nx584.NX584ZoneSensor(zone, "motion")
assert sensor.name == "foo"
assert not sensor.should_poll
assert sensor.is_on
assert sensor.extra_state_attributes["zone_number"] == 1
assert sensor.extra_state_attributes["bypassed"]
zone["state"] = False
zone["bypassed"] = False
assert not sensor.is_on
assert not sensor.extra_state_attributes["bypassed"]
@mock.patch.object(nx584.NX584ZoneSensor, "schedule_update_ha_state")
def test_nx584_watcher_process_zone_event(mock_update):
"""Test the processing of zone events."""