mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Add unique id to Manual alarm (#123588)
This commit is contained in:
parent
b19758ff71
commit
bbefe47aeb
@ -30,9 +30,10 @@ async def async_setup_entry(
|
|||||||
"""Set up the Demo config entry."""
|
"""Set up the Demo config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoAlarm( # type:ignore[no-untyped-call]
|
ManualAlarm( # type:ignore[no-untyped-call]
|
||||||
hass,
|
hass,
|
||||||
"Security",
|
"Security",
|
||||||
|
"demo_alarm_control_panel",
|
||||||
"1234",
|
"1234",
|
||||||
None,
|
None,
|
||||||
True,
|
True,
|
||||||
@ -74,9 +75,3 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DemoAlarm(ManualAlarm):
|
|
||||||
"""Demo Alarm Control Panel."""
|
|
||||||
|
|
||||||
_attr_unique_id = "demo_alarm_control_panel"
|
|
||||||
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PLATFORM,
|
CONF_PLATFORM,
|
||||||
CONF_TRIGGER_TIME,
|
CONF_TRIGGER_TIME,
|
||||||
|
CONF_UNIQUE_ID,
|
||||||
STATE_ALARM_ARMED_AWAY,
|
STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_CUSTOM_BYPASS,
|
STATE_ALARM_ARMED_CUSTOM_BYPASS,
|
||||||
STATE_ALARM_ARMED_HOME,
|
STATE_ALARM_ARMED_HOME,
|
||||||
@ -122,6 +123,7 @@ PLATFORM_SCHEMA = vol.Schema(
|
|||||||
{
|
{
|
||||||
vol.Required(CONF_PLATFORM): "manual",
|
vol.Required(CONF_PLATFORM): "manual",
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_ALARM_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_ALARM_NAME): cv.string,
|
||||||
|
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
||||||
vol.Exclusive(CONF_CODE, "code validation"): cv.string,
|
vol.Exclusive(CONF_CODE, "code validation"): cv.string,
|
||||||
vol.Exclusive(CONF_CODE_TEMPLATE, "code validation"): cv.template,
|
vol.Exclusive(CONF_CODE_TEMPLATE, "code validation"): cv.template,
|
||||||
vol.Optional(CONF_CODE_ARM_REQUIRED, default=True): cv.boolean,
|
vol.Optional(CONF_CODE_ARM_REQUIRED, default=True): cv.boolean,
|
||||||
@ -179,6 +181,7 @@ def setup_platform(
|
|||||||
ManualAlarm(
|
ManualAlarm(
|
||||||
hass,
|
hass,
|
||||||
config[CONF_NAME],
|
config[CONF_NAME],
|
||||||
|
config.get(CONF_UNIQUE_ID),
|
||||||
config.get(CONF_CODE),
|
config.get(CONF_CODE),
|
||||||
config.get(CONF_CODE_TEMPLATE),
|
config.get(CONF_CODE_TEMPLATE),
|
||||||
config.get(CONF_CODE_ARM_REQUIRED),
|
config.get(CONF_CODE_ARM_REQUIRED),
|
||||||
@ -205,6 +208,7 @@ class ManualAlarm(AlarmControlPanelEntity, RestoreEntity):
|
|||||||
self,
|
self,
|
||||||
hass,
|
hass,
|
||||||
name,
|
name,
|
||||||
|
unique_id,
|
||||||
code,
|
code,
|
||||||
code_template,
|
code_template,
|
||||||
code_arm_required,
|
code_arm_required,
|
||||||
@ -215,6 +219,7 @@ class ManualAlarm(AlarmControlPanelEntity, RestoreEntity):
|
|||||||
self._state = STATE_ALARM_DISARMED
|
self._state = STATE_ALARM_DISARMED
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
|
self._attr_unique_id = unique_id
|
||||||
if code_template:
|
if code_template:
|
||||||
self._code = code_template
|
self._code = code_template
|
||||||
self._code.hass = hass
|
self._code.hass = hass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user