mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Move configuration details to docs
This commit is contained in:
parent
38e1cef30e
commit
a583525110
@ -1,37 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel.manual
|
homeassistant.components.alarm_control_panel.manual
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Support for manual alarms.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/alarm_control_panel.manual.html
|
||||||
alarm_control_panel:
|
|
||||||
platform: manual
|
|
||||||
name: "HA Alarm"
|
|
||||||
code: "mySecretCode"
|
|
||||||
pending_time: 60
|
|
||||||
trigger_time: 120
|
|
||||||
|
|
||||||
Variables:
|
|
||||||
|
|
||||||
name
|
|
||||||
*Optional
|
|
||||||
The name of the alarm. Default is 'HA Alarm'.
|
|
||||||
|
|
||||||
code
|
|
||||||
*Optional
|
|
||||||
If defined, specifies a code to arm or disarm the alarm in the frontend.
|
|
||||||
|
|
||||||
pending_time
|
|
||||||
*Optional
|
|
||||||
The time in seconds of the pending time before arming the alarm.
|
|
||||||
Default is 60 seconds.
|
|
||||||
|
|
||||||
trigger_time
|
|
||||||
*Optional
|
|
||||||
The time in seconds of the trigger time in which the alarm is firing.
|
|
||||||
Default is 120 seconds.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
import homeassistant.components.alarm_control_panel as alarm
|
import homeassistant.components.alarm_control_panel as alarm
|
||||||
@ -66,7 +40,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
class ManualAlarm(alarm.AlarmControlPanel):
|
class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
""" represents an alarm status within home assistant. """
|
""" Represents an alarm status. """
|
||||||
|
|
||||||
def __init__(self, hass, name, code, pending_time, trigger_time):
|
def __init__(self, hass, name, code, pending_time, trigger_time):
|
||||||
self._state = STATE_ALARM_DISARMED
|
self._state = STATE_ALARM_DISARMED
|
||||||
@ -80,7 +54,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
""" No polling needed """
|
""" No polling needed. """
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -95,11 +69,11 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
""" One or more characters """
|
""" One or more characters. """
|
||||||
return None if self._code is None else '.+'
|
return None if self._code is None else '.+'
|
||||||
|
|
||||||
def update_state(self, state, pending_to):
|
def update_state(self, state, pending_to):
|
||||||
""" changes between state with delay """
|
""" Changes between state with delay. """
|
||||||
self._state = state
|
self._state = state
|
||||||
self._state_ts = dt_util.utcnow()
|
self._state_ts = dt_util.utcnow()
|
||||||
self._pending_to = pending_to
|
self._pending_to = pending_to
|
||||||
@ -118,7 +92,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
|||||||
self.update_state(STATE_ALARM_PENDING, STATE_ALARM_ARMED_HOME)
|
self.update_state(STATE_ALARM_PENDING, STATE_ALARM_ARMED_HOME)
|
||||||
|
|
||||||
def delayed_alarm_arm_home(event_time):
|
def delayed_alarm_arm_home(event_time):
|
||||||
""" callback for delayed action """
|
""" Callback for delayed action. """
|
||||||
if self._pending_to == STATE_ALARM_ARMED_HOME and \
|
if self._pending_to == STATE_ALARM_ARMED_HOME and \
|
||||||
dt_util.utcnow() - self._state_ts >= self._pending_time:
|
dt_util.utcnow() - self._state_ts >= self._pending_time:
|
||||||
self.update_state(STATE_ALARM_ARMED_HOME, None)
|
self.update_state(STATE_ALARM_ARMED_HOME, None)
|
||||||
@ -134,7 +108,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
|||||||
self.update_state(STATE_ALARM_PENDING, STATE_ALARM_ARMED_AWAY)
|
self.update_state(STATE_ALARM_PENDING, STATE_ALARM_ARMED_AWAY)
|
||||||
|
|
||||||
def delayed_alarm_arm_away(event_time):
|
def delayed_alarm_arm_away(event_time):
|
||||||
""" callback for delayed action """
|
""" Callback for delayed action. """
|
||||||
if self._pending_to == STATE_ALARM_ARMED_AWAY and \
|
if self._pending_to == STATE_ALARM_ARMED_AWAY and \
|
||||||
dt_util.utcnow() - self._state_ts >= self._pending_time:
|
dt_util.utcnow() - self._state_ts >= self._pending_time:
|
||||||
self.update_state(STATE_ALARM_ARMED_AWAY, None)
|
self.update_state(STATE_ALARM_ARMED_AWAY, None)
|
||||||
@ -155,7 +129,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
|||||||
self.update_state(STATE_ALARM_TRIGGERED, STATE_ALARM_DISARMED)
|
self.update_state(STATE_ALARM_TRIGGERED, STATE_ALARM_DISARMED)
|
||||||
|
|
||||||
def delayed_alarm_disarm(event_time):
|
def delayed_alarm_disarm(event_time):
|
||||||
""" callback for delayed action """
|
""" Callback for delayed action. """
|
||||||
if self._pending_to == STATE_ALARM_DISARMED and \
|
if self._pending_to == STATE_ALARM_DISARMED and \
|
||||||
dt_util.utcnow() - self._state_ts >= self._trigger_time:
|
dt_util.utcnow() - self._state_ts >= self._trigger_time:
|
||||||
self.update_state(STATE_ALARM_DISARMED, None)
|
self.update_state(STATE_ALARM_DISARMED, None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user