mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
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:
parent
cfabb06a7a
commit
f8d82bbf80
@ -42,6 +42,7 @@ class TotalConnectAlarm(alarm.AlarmControlPanelEntity):
|
|||||||
"""Initialize the TotalConnect status."""
|
"""Initialize the TotalConnect status."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._location_id = location_id
|
self._location_id = location_id
|
||||||
|
self._unique_id = str(location_id)
|
||||||
self._client = client
|
self._client = client
|
||||||
self._state = None
|
self._state = None
|
||||||
self._extra_state_attributes = {}
|
self._extra_state_attributes = {}
|
||||||
@ -51,6 +52,11 @@ class TotalConnectAlarm(alarm.AlarmControlPanelEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return the unique id."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
|
@ -9,8 +9,10 @@ from homeassistant.setup import async_setup_component
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
LOCATION_ID = "123456"
|
||||||
|
|
||||||
LOCATION_INFO_BASIC_NORMAL = {
|
LOCATION_INFO_BASIC_NORMAL = {
|
||||||
"LocationID": "123456",
|
"LocationID": LOCATION_ID,
|
||||||
"LocationName": "test",
|
"LocationName": "test",
|
||||||
"SecurityDeviceID": "987654",
|
"SecurityDeviceID": "987654",
|
||||||
"PhotoURL": "http://www.example.com/some/path/to/file.jpg",
|
"PhotoURL": "http://www.example.com/some/path/to/file.jpg",
|
||||||
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
|
LOCATION_ID,
|
||||||
RESPONSE_ARM_FAILURE,
|
RESPONSE_ARM_FAILURE,
|
||||||
RESPONSE_ARM_SUCCESS,
|
RESPONSE_ARM_SUCCESS,
|
||||||
RESPONSE_ARMED_AWAY,
|
RESPONSE_ARMED_AWAY,
|
||||||
@ -45,6 +46,11 @@ async def test_attributes(hass):
|
|||||||
mock_request.assert_called_once()
|
mock_request.assert_called_once()
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "test"
|
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):
|
async def test_arm_home_success(hass):
|
||||||
"""Test arm home method success."""
|
"""Test arm home method success."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user