Add unique_id to canary alarm_control_panel (#40041)

* add unique_id to canary alarm_control_panel

* Update test_alarm_control_panel.py

* Update alarm_control_panel.py

* Apply suggestions from code review

Co-authored-by: J. Nick Koston <nick@koston.org>

Co-authored-by: J. Nick Koston <nick@koston.org>
pull/40054/head
Chris Talkington 2020-09-13 18:52:40 -05:00 committed by GitHub
parent ae8c9d82bc
commit 9511103e26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,11 @@ class CanaryAlarm(AlarmControlPanelEntity):
location = self._data.get_location(self._location_id)
return location.name
@property
def unique_id(self):
"""Return the unique ID of the alarm."""
return str(self._location_id)
@property
def state(self):
"""Return the state of the device."""

View File

@ -50,7 +50,8 @@ async def test_alarm_control_panel(hass, canary) -> None:
entity_id = "alarm_control_panel.home"
entity_entry = registry.async_get(entity_id)
assert not entity_entry
assert entity_entry
assert entity_entry.unique_id == "100"
state = hass.states.get(entity_id)
assert state