From f8d82bbf8034cc1b61e9c62d087ae39f40f78e86 Mon Sep 17 00:00:00 2001 From: Austin Mroczek Date: Mon, 3 May 2021 02:38:59 -0700 Subject: [PATCH] Add unique_id to TotalConnect alarm_control_panel (#49961) * add unique_id to alarm_control_panel * Update homeassistant/components/totalconnect/alarm_control_panel.py Co-authored-by: Martin Hjelmare Co-authored-by: Martin Hjelmare --- .../components/totalconnect/alarm_control_panel.py | 6 ++++++ tests/components/totalconnect/common.py | 4 +++- tests/components/totalconnect/test_alarm_control_panel.py | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/totalconnect/alarm_control_panel.py b/homeassistant/components/totalconnect/alarm_control_panel.py index c277198b683..ae999ade9ac 100644 --- a/homeassistant/components/totalconnect/alarm_control_panel.py +++ b/homeassistant/components/totalconnect/alarm_control_panel.py @@ -42,6 +42,7 @@ class TotalConnectAlarm(alarm.AlarmControlPanelEntity): """Initialize the TotalConnect status.""" self._name = name self._location_id = location_id + self._unique_id = str(location_id) self._client = client self._state = None self._extra_state_attributes = {} @@ -51,6 +52,11 @@ class TotalConnectAlarm(alarm.AlarmControlPanelEntity): """Return the name of the device.""" return self._name + @property + def unique_id(self): + """Return the unique id.""" + return self._unique_id + @property def state(self): """Return the state of the device.""" diff --git a/tests/components/totalconnect/common.py b/tests/components/totalconnect/common.py index d4285c07425..6f9fef4b7c0 100644 --- a/tests/components/totalconnect/common.py +++ b/tests/components/totalconnect/common.py @@ -9,8 +9,10 @@ from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry +LOCATION_ID = "123456" + LOCATION_INFO_BASIC_NORMAL = { - "LocationID": "123456", + "LocationID": LOCATION_ID, "LocationName": "test", "SecurityDeviceID": "987654", "PhotoURL": "http://www.example.com/some/path/to/file.jpg", diff --git a/tests/components/totalconnect/test_alarm_control_panel.py b/tests/components/totalconnect/test_alarm_control_panel.py index 12ad53733b5..9d8dbaf0358 100644 --- a/tests/components/totalconnect/test_alarm_control_panel.py +++ b/tests/components/totalconnect/test_alarm_control_panel.py @@ -17,6 +17,7 @@ from homeassistant.const import ( from homeassistant.exceptions import HomeAssistantError from .common import ( + LOCATION_ID, RESPONSE_ARM_FAILURE, RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY, @@ -45,6 +46,11 @@ async def test_attributes(hass): mock_request.assert_called_once() assert state.attributes.get(ATTR_FRIENDLY_NAME) == "test" + entity_registry = await hass.helpers.entity_registry.async_get_registry() + entry = entity_registry.async_get(ENTITY_ID) + # TotalConnect alarm device unique_id is the location_id + assert entry.unique_id == LOCATION_ID + async def test_arm_home_success(hass): """Test arm home method success."""