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 <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Austin Mroczek 2021-05-03 02:38:59 -07:00 committed by GitHub
parent cfabb06a7a
commit f8d82bbf80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -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."""

View File

@ -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",

View File

@ -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."""