core/homeassistant/components/demo/alarm_control_panel.py

66 lines
2.5 KiB
Python
Raw Normal View History

"""Demo platform that has two fake alarm control panels."""
import datetime
from homeassistant.components.manual.alarm_control_panel import ManualAlarm
from homeassistant.const import (
CONF_ARMING_TIME,
CONF_DELAY_TIME,
CONF_TRIGGER_TIME,
2019-07-31 19:25:30 +00:00
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_CUSTOM_BYPASS,
STATE_ALARM_ARMED_HOME,
STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_DISARMED,
STATE_ALARM_TRIGGERED,
)
2019-07-31 19:25:30 +00:00
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Demo alarm control panel platform."""
2019-07-31 19:25:30 +00:00
async_add_entities(
[
ManualAlarm(
hass,
"Alarm",
"1234",
None,
True,
False,
{
STATE_ALARM_ARMED_AWAY: {
CONF_ARMING_TIME: datetime.timedelta(seconds=5),
2019-07-31 19:25:30 +00:00
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
CONF_TRIGGER_TIME: datetime.timedelta(seconds=10),
},
STATE_ALARM_ARMED_HOME: {
CONF_ARMING_TIME: datetime.timedelta(seconds=5),
2019-07-31 19:25:30 +00:00
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
CONF_TRIGGER_TIME: datetime.timedelta(seconds=10),
},
STATE_ALARM_ARMED_NIGHT: {
CONF_ARMING_TIME: datetime.timedelta(seconds=5),
2019-07-31 19:25:30 +00:00
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
CONF_TRIGGER_TIME: datetime.timedelta(seconds=10),
},
STATE_ALARM_DISARMED: {
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
CONF_TRIGGER_TIME: datetime.timedelta(seconds=10),
},
STATE_ALARM_ARMED_CUSTOM_BYPASS: {
CONF_ARMING_TIME: datetime.timedelta(seconds=5),
2019-07-31 19:25:30 +00:00
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
CONF_TRIGGER_TIME: datetime.timedelta(seconds=10),
},
STATE_ALARM_TRIGGERED: {
CONF_ARMING_TIME: datetime.timedelta(seconds=5)
2019-07-31 19:25:30 +00:00
},
},
)
]
)
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)