From 5f8dcd45c1a4279f792f39ef6deffb8f8677cef5 Mon Sep 17 00:00:00 2001 From: mreiling <45905227+mreiling@users.noreply.github.com> Date: Tue, 9 Jun 2020 05:19:46 -0700 Subject: [PATCH] Add NX584 alarm binary_sensor zone_number attribute (#36552) --- homeassistant/components/nx584/binary_sensor.py | 5 +++++ tests/components/nx584/test_binary_sensor.py | 1 + 2 files changed, 6 insertions(+) diff --git a/homeassistant/components/nx584/binary_sensor.py b/homeassistant/components/nx584/binary_sensor.py index d12f337c171..127ce02b371 100644 --- a/homeassistant/components/nx584/binary_sensor.py +++ b/homeassistant/components/nx584/binary_sensor.py @@ -101,6 +101,11 @@ class NX584ZoneSensor(BinarySensorEntity): # True means "faulted" or "open" or "abnormal state" return self._zone["state"] + @property + def device_state_attributes(self): + """Return the state attributes.""" + return {"zone_number": self._zone["number"]} + class NX584Watcher(threading.Thread): """Event listener thread to process NX584 events.""" diff --git a/tests/components/nx584/test_binary_sensor.py b/tests/components/nx584/test_binary_sensor.py index a9f3e6df7f6..89892bb06f0 100644 --- a/tests/components/nx584/test_binary_sensor.py +++ b/tests/components/nx584/test_binary_sensor.py @@ -135,6 +135,7 @@ class TestNX584ZoneSensor(unittest.TestCase): assert "foo" == sensor.name assert not sensor.should_poll assert sensor.is_on + assert sensor.device_state_attributes["zone_number"] == 1 zone["state"] = False assert not sensor.is_on