* Manual Alarm Control Panel: use proper "Arming" state * Update previous and next attributes * add CONF_ARMING_TIME * Split up arming and pending time, pending_time --> arming_time * update tests * fix issort * fix issort * fix demo platform * fix alarm test * remove arming_time from the triggered state * Match previous default "delay_time" * fix tests * fix arming state when triggering * fix arming _arming_time_by_state for Triggering state * change to not in list * Update homeassistant/components/manual/alarm_control_panel.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * async_update_ha_state -> async_write_ha_state * black formatting * add Callback Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * import callback * update device triggers alarm_control_panel * Update test_device_trigger.py * Update device_trigger.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
"""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,
|
|
STATE_ALARM_ARMED_AWAY,
|
|
STATE_ALARM_ARMED_CUSTOM_BYPASS,
|
|
STATE_ALARM_ARMED_HOME,
|
|
STATE_ALARM_ARMED_NIGHT,
|
|
STATE_ALARM_DISARMED,
|
|
STATE_ALARM_TRIGGERED,
|
|
)
|
|
|
|
|
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
|
"""Set up the Demo alarm control panel platform."""
|
|
async_add_entities(
|
|
[
|
|
ManualAlarm(
|
|
hass,
|
|
"Alarm",
|
|
"1234",
|
|
None,
|
|
True,
|
|
False,
|
|
{
|
|
STATE_ALARM_ARMED_AWAY: {
|
|
CONF_ARMING_TIME: datetime.timedelta(seconds=5),
|
|
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),
|
|
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),
|
|
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),
|
|
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
|
|
CONF_TRIGGER_TIME: datetime.timedelta(seconds=10),
|
|
},
|
|
STATE_ALARM_TRIGGERED: {
|
|
CONF_ARMING_TIME: datetime.timedelta(seconds=5)
|
|
},
|
|
},
|
|
)
|
|
]
|
|
)
|
|
|
|
|
|
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)
|