2015-11-26 18:09:32 +00:00
|
|
|
"""
|
|
|
|
homeassistant.components.alarm_control_panel.demo
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Demo platform that has two fake alarm control panels.
|
|
|
|
"""
|
2015-11-26 23:40:51 +00:00
|
|
|
import homeassistant.components.alarm_control_panel.manual as Alarm
|
|
|
|
from homeassistant.const import (STATE_ALARM_DISARMED,
|
2015-11-26 18:09:32 +00:00
|
|
|
STATE_ALARM_ARMED_AWAY)
|
|
|
|
|
|
|
|
|
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
|
|
|
""" Sets up the Demo alarm control panels. """
|
|
|
|
add_devices([
|
2015-11-26 23:40:51 +00:00
|
|
|
|
|
|
|
DemoAlarmControlPanel(hass, 'Front door', '1234', 2, 4,
|
|
|
|
STATE_ALARM_DISARMED),
|
|
|
|
DemoAlarmControlPanel(hass, 'Safe', '1234', 2, 4,
|
|
|
|
STATE_ALARM_ARMED_AWAY),
|
2015-11-26 18:09:32 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
|
2015-11-26 23:40:51 +00:00
|
|
|
# pylint: disable=too-many-arguments
|
|
|
|
class DemoAlarmControlPanel(Alarm.ManualAlarm):
|
2015-11-26 18:09:32 +00:00
|
|
|
""" A Demo alarm control panel. """
|
|
|
|
|
2015-11-26 23:40:51 +00:00
|
|
|
def __init__(self, hass, name, code, pending_time, trigger_time, state):
|
|
|
|
super().__init__(hass, name, code, pending_time, trigger_time)
|
2015-11-26 18:09:32 +00:00
|
|
|
self._state = state
|
|
|
|
|
|
|
|
@property
|
|
|
|
def should_poll(self):
|
2015-11-26 23:40:51 +00:00
|
|
|
""" No polling needed for a demo panel. """
|
2015-11-26 18:09:32 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
@property
|
|
|
|
def state(self):
|
|
|
|
""" Returns the state of the device. """
|
|
|
|
return self._state
|