Modify docstrings to match PEP257
This commit is contained in:
parent
18f48191d9
commit
1e97d31711
6 changed files with 66 additions and 85 deletions
|
@ -1,7 +1,8 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Component to interface with a alarm control panel.
|
Component to interface with a alarm control panel.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/alarm_control_panel/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -41,7 +42,7 @@ ATTR_TO_PROPERTY = [
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
""" Track states and offer events for sensors. """
|
"""Track states and offer events for sensors."""
|
||||||
component = EntityComponent(
|
component = EntityComponent(
|
||||||
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL,
|
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL,
|
||||||
DISCOVERY_PLATFORMS)
|
DISCOVERY_PLATFORMS)
|
||||||
|
@ -49,7 +50,7 @@ def setup(hass, config):
|
||||||
component.setup(config)
|
component.setup(config)
|
||||||
|
|
||||||
def alarm_service_handler(service):
|
def alarm_service_handler(service):
|
||||||
""" Maps services to methods on Alarm. """
|
"""Maps services to methods on Alarm."""
|
||||||
target_alarms = component.extract_from_service(service)
|
target_alarms = component.extract_from_service(service)
|
||||||
|
|
||||||
if ATTR_CODE not in service.data:
|
if ATTR_CODE not in service.data:
|
||||||
|
@ -75,7 +76,7 @@ def setup(hass, config):
|
||||||
|
|
||||||
|
|
||||||
def alarm_disarm(hass, code=None, entity_id=None):
|
def alarm_disarm(hass, code=None, entity_id=None):
|
||||||
""" Send the alarm the command for disarm. """
|
"""Send the alarm the command for disarm."""
|
||||||
data = {}
|
data = {}
|
||||||
if code:
|
if code:
|
||||||
data[ATTR_CODE] = code
|
data[ATTR_CODE] = code
|
||||||
|
@ -86,7 +87,7 @@ def alarm_disarm(hass, code=None, entity_id=None):
|
||||||
|
|
||||||
|
|
||||||
def alarm_arm_home(hass, code=None, entity_id=None):
|
def alarm_arm_home(hass, code=None, entity_id=None):
|
||||||
""" Send the alarm the command for arm home. """
|
"""Send the alarm the command for arm home."""
|
||||||
data = {}
|
data = {}
|
||||||
if code:
|
if code:
|
||||||
data[ATTR_CODE] = code
|
data[ATTR_CODE] = code
|
||||||
|
@ -97,7 +98,7 @@ def alarm_arm_home(hass, code=None, entity_id=None):
|
||||||
|
|
||||||
|
|
||||||
def alarm_arm_away(hass, code=None, entity_id=None):
|
def alarm_arm_away(hass, code=None, entity_id=None):
|
||||||
""" Send the alarm the command for arm away. """
|
"""Send the alarm the command for arm away."""
|
||||||
data = {}
|
data = {}
|
||||||
if code:
|
if code:
|
||||||
data[ATTR_CODE] = code
|
data[ATTR_CODE] = code
|
||||||
|
@ -108,7 +109,7 @@ def alarm_arm_away(hass, code=None, entity_id=None):
|
||||||
|
|
||||||
|
|
||||||
def alarm_trigger(hass, code=None, entity_id=None):
|
def alarm_trigger(hass, code=None, entity_id=None):
|
||||||
""" Send the alarm the command for trigger. """
|
"""Send the alarm the command for trigger."""
|
||||||
data = {}
|
data = {}
|
||||||
if code:
|
if code:
|
||||||
data[ATTR_CODE] = code
|
data[ATTR_CODE] = code
|
||||||
|
@ -120,32 +121,31 @@ def alarm_trigger(hass, code=None, entity_id=None):
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
class AlarmControlPanel(Entity):
|
class AlarmControlPanel(Entity):
|
||||||
""" ABC for alarm control devices. """
|
"""An ABC for alarm control devices."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
""" regex for code format or None if no code is required. """
|
"""Regex for code format or None if no code is required."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
"""Send disarm command."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
"""Send arm home command."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
"""Send arm away command."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_trigger(self, code=None):
|
def alarm_trigger(self, code=None):
|
||||||
""" Send alarm trigger command. """
|
"""Send alarm trigger command."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
""" Return the state attributes. """
|
"""Return the state attributes."""
|
||||||
state_attr = {
|
state_attr = {
|
||||||
ATTR_CODE_FORMAT: self.code_format,
|
ATTR_CODE_FORMAT: self.code_format,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel.alarmdotcom
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Interfaces with Verisure alarm control panel.
|
Interfaces with Verisure alarm control panel.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -23,8 +21,7 @@ DEFAULT_NAME = 'Alarm.com'
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Setup an Alarm.com control panel. """
|
"""Setup an Alarm.com control panel."""
|
||||||
|
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
|
|
||||||
|
@ -42,8 +39,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 AlarmDotCom(alarm.AlarmControlPanel):
|
class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
""" Represents a Alarm.com status. """
|
"""Represents a Alarm.com status."""
|
||||||
|
|
||||||
def __init__(self, hass, name, code, username, password):
|
def __init__(self, hass, name, code, username, password):
|
||||||
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
||||||
self._alarm = Alarmdotcom(username, password, timeout=10)
|
self._alarm = Alarmdotcom(username, password, timeout=10)
|
||||||
|
@ -55,22 +51,22 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
""" No polling needed. """
|
"""No polling needed."""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the device. """
|
"""Returns the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
""" One or more characters if code is defined. """
|
"""One or more characters if code is defined."""
|
||||||
return None if self._code is None else '.+'
|
return None if self._code is None else '.+'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
"""Returns the state of the device."""
|
||||||
if self._alarm.state == 'Disarmed':
|
if self._alarm.state == 'Disarmed':
|
||||||
return STATE_ALARM_DISARMED
|
return STATE_ALARM_DISARMED
|
||||||
elif self._alarm.state == 'Armed Stay':
|
elif self._alarm.state == 'Armed Stay':
|
||||||
|
@ -81,7 +77,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
return STATE_UNKNOWN
|
return STATE_UNKNOWN
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
"""Send disarm command."""
|
||||||
if not self._validate_code(code, 'arming home'):
|
if not self._validate_code(code, 'arming home'):
|
||||||
return
|
return
|
||||||
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
||||||
|
@ -90,7 +86,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
_alarm.disarm()
|
_alarm.disarm()
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
"""Send arm home command."""
|
||||||
if not self._validate_code(code, 'arming home'):
|
if not self._validate_code(code, 'arming home'):
|
||||||
return
|
return
|
||||||
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
||||||
|
@ -99,7 +95,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
_alarm.arm_stay()
|
_alarm.arm_stay()
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
"""Send arm away command."""
|
||||||
if not self._validate_code(code, 'arming home'):
|
if not self._validate_code(code, 'arming home'):
|
||||||
return
|
return
|
||||||
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
|
||||||
|
@ -108,7 +104,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
_alarm.arm_away()
|
_alarm.arm_away()
|
||||||
|
|
||||||
def _validate_code(self, code, state):
|
def _validate_code(self, code, state):
|
||||||
""" Validate given code. """
|
"""Validate given code."""
|
||||||
check = self._code is None or code == self._code
|
check = self._code is None or code == self._code
|
||||||
if not check:
|
if not check:
|
||||||
_LOGGER.warning('Wrong code entered for %s', state)
|
_LOGGER.warning('Wrong code entered for %s', state)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel.manual
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Support for manual alarms.
|
Support for manual alarms.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -24,8 +22,7 @@ DEFAULT_TRIGGER_TIME = 120
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the manual alarm platform. """
|
"""Sets up the manual alarm platform."""
|
||||||
|
|
||||||
add_devices([ManualAlarm(
|
add_devices([ManualAlarm(
|
||||||
hass,
|
hass,
|
||||||
config.get('name', DEFAULT_ALARM_NAME),
|
config.get('name', DEFAULT_ALARM_NAME),
|
||||||
|
@ -45,7 +42,6 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
When triggered, will be pending for 'trigger_time'. After that will be
|
When triggered, will be pending for 'trigger_time'. After that will be
|
||||||
triggered for 'trigger_time', after that we return to disarmed.
|
triggered for 'trigger_time', after that we return to disarmed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
@ -57,17 +53,17 @@ 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
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the device. """
|
"""Returns the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
"""Returns the state of the device."""
|
||||||
if self._state in (STATE_ALARM_ARMED_HOME,
|
if self._state in (STATE_ALARM_ARMED_HOME,
|
||||||
STATE_ALARM_ARMED_AWAY) and \
|
STATE_ALARM_ARMED_AWAY) and \
|
||||||
self._pending_time and self._state_ts + self._pending_time > \
|
self._pending_time and self._state_ts + self._pending_time > \
|
||||||
|
@ -85,11 +81,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 alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
"""Send disarm command."""
|
||||||
if not self._validate_code(code, STATE_ALARM_DISARMED):
|
if not self._validate_code(code, STATE_ALARM_DISARMED):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -98,7 +94,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
self.update_ha_state()
|
self.update_ha_state()
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
"""Send arm home command."""
|
||||||
if not self._validate_code(code, STATE_ALARM_ARMED_HOME):
|
if not self._validate_code(code, STATE_ALARM_ARMED_HOME):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -112,7 +108,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
self._state_ts + self._pending_time)
|
self._state_ts + self._pending_time)
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
"""Send arm away command."""
|
||||||
if not self._validate_code(code, STATE_ALARM_ARMED_AWAY):
|
if not self._validate_code(code, STATE_ALARM_ARMED_AWAY):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -126,7 +122,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
self._state_ts + self._pending_time)
|
self._state_ts + self._pending_time)
|
||||||
|
|
||||||
def alarm_trigger(self, code=None):
|
def alarm_trigger(self, code=None):
|
||||||
""" Send alarm trigger command. No code needed. """
|
"""Send alarm trigger command. No code needed."""
|
||||||
self._state = STATE_ALARM_TRIGGERED
|
self._state = STATE_ALARM_TRIGGERED
|
||||||
self._state_ts = dt_util.utcnow()
|
self._state_ts = dt_util.utcnow()
|
||||||
self.update_ha_state()
|
self.update_ha_state()
|
||||||
|
@ -141,7 +137,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
self._state_ts + self._pending_time + self._trigger_time)
|
self._state_ts + self._pending_time + self._trigger_time)
|
||||||
|
|
||||||
def _validate_code(self, code, state):
|
def _validate_code(self, code, state):
|
||||||
""" Validate given code. """
|
"""Validate given code."""
|
||||||
check = self._code is None or code == self._code
|
check = self._code is None or code == self._code
|
||||||
if not check:
|
if not check:
|
||||||
_LOGGER.warning('Invalid code given for %s', state)
|
_LOGGER.warning('Invalid code given for %s', state)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel.mqtt
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
This platform enables the possibility to control a MQTT alarm.
|
This platform enables the possibility to control a MQTT alarm.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -26,8 +24,7 @@ DEPENDENCIES = ['mqtt']
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the MQTT platform. """
|
"""Sets up the MQTT platform."""
|
||||||
|
|
||||||
if config.get('state_topic') is None:
|
if config.get('state_topic') is None:
|
||||||
_LOGGER.error("Missing required variable: state_topic")
|
_LOGGER.error("Missing required variable: state_topic")
|
||||||
return False
|
return False
|
||||||
|
@ -51,8 +48,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 MqttAlarm(alarm.AlarmControlPanel):
|
class MqttAlarm(alarm.AlarmControlPanel):
|
||||||
""" represents a MQTT alarm status within home assistant. """
|
"""Represents a MQTT alarm status."""
|
||||||
|
|
||||||
def __init__(self, hass, name, state_topic, command_topic, qos,
|
def __init__(self, hass, name, state_topic, command_topic, qos,
|
||||||
payload_disarm, payload_arm_home, payload_arm_away, code):
|
payload_disarm, payload_arm_home, payload_arm_away, code):
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
|
@ -67,7 +63,7 @@ class MqttAlarm(alarm.AlarmControlPanel):
|
||||||
self._code = str(code) if code else None
|
self._code = str(code) if code else None
|
||||||
|
|
||||||
def message_received(topic, payload, qos):
|
def message_received(topic, payload, qos):
|
||||||
""" A new MQTT message has been received. """
|
"""A new MQTT message has been received."""
|
||||||
if payload not in (STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME,
|
if payload not in (STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME,
|
||||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_PENDING,
|
STATE_ALARM_ARMED_AWAY, STATE_ALARM_PENDING,
|
||||||
STATE_ALARM_TRIGGERED):
|
STATE_ALARM_TRIGGERED):
|
||||||
|
@ -80,12 +76,12 @@ class MqttAlarm(alarm.AlarmControlPanel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
""" No polling needed """
|
"""No polling needed."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the device. """
|
"""Returns the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -95,32 +91,32 @@ class MqttAlarm(alarm.AlarmControlPanel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
""" One or more characters if code is defined """
|
"""One or more characters if code is defined."""
|
||||||
return None if self._code is None else '.+'
|
return None if self._code is None else '.+'
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
"""Send disarm command."""
|
||||||
if not self._validate_code(code, 'disarming'):
|
if not self._validate_code(code, 'disarming'):
|
||||||
return
|
return
|
||||||
mqtt.publish(self.hass, self._command_topic,
|
mqtt.publish(self.hass, self._command_topic,
|
||||||
self._payload_disarm, self._qos)
|
self._payload_disarm, self._qos)
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
"""Send arm home command."""
|
||||||
if not self._validate_code(code, 'arming home'):
|
if not self._validate_code(code, 'arming home'):
|
||||||
return
|
return
|
||||||
mqtt.publish(self.hass, self._command_topic,
|
mqtt.publish(self.hass, self._command_topic,
|
||||||
self._payload_arm_home, self._qos)
|
self._payload_arm_home, self._qos)
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
"""Send arm away command."""
|
||||||
if not self._validate_code(code, 'arming away'):
|
if not self._validate_code(code, 'arming away'):
|
||||||
return
|
return
|
||||||
mqtt.publish(self.hass, self._command_topic,
|
mqtt.publish(self.hass, self._command_topic,
|
||||||
self._payload_arm_away, self._qos)
|
self._payload_arm_away, self._qos)
|
||||||
|
|
||||||
def _validate_code(self, code, state):
|
def _validate_code(self, code, state):
|
||||||
""" Validate given code. """
|
"""Validate given code."""
|
||||||
check = self._code is None or code == self._code
|
check = self._code is None or code == self._code
|
||||||
if not check:
|
if not check:
|
||||||
_LOGGER.warning('Wrong code entered for %s', state)
|
_LOGGER.warning('Wrong code entered for %s', state)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel.nx584
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Support for NX584 alarm control panels.
|
Support for NX584 alarm control panels.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
|
@ -16,12 +14,11 @@ from homeassistant.const import (
|
||||||
STATE_UNKNOWN)
|
STATE_UNKNOWN)
|
||||||
|
|
||||||
REQUIREMENTS = ['pynx584==0.2']
|
REQUIREMENTS = ['pynx584==0.2']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Setup nx584. """
|
"""Setup nx584 platform."""
|
||||||
host = config.get('host', 'localhost:5007')
|
host = config.get('host', 'localhost:5007')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -32,7 +29,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
||||||
|
|
||||||
class NX584Alarm(alarm.AlarmControlPanel):
|
class NX584Alarm(alarm.AlarmControlPanel):
|
||||||
""" NX584-based alarm panel. """
|
"""Represents the NX584-based alarm panel. """
|
||||||
def __init__(self, hass, host, name):
|
def __init__(self, hass, host, name):
|
||||||
from nx584 import client
|
from nx584 import client
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
@ -46,22 +43,22 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
""" Polling needed. """
|
"""Polling needed."""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the device. """
|
"""Returns the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
""" Characters if code is defined. """
|
"""Characters if code is defined."""
|
||||||
return '[0-9]{4}([0-9]{2})?'
|
return '[0-9]{4}([0-9]{2})?'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
"""Returns the state of the device."""
|
||||||
try:
|
try:
|
||||||
part = self._alarm.list_partitions()[0]
|
part = self._alarm.list_partitions()[0]
|
||||||
zones = self._alarm.list_zones()
|
zones = self._alarm.list_zones()
|
||||||
|
@ -90,17 +87,17 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
||||||
return STATE_ALARM_ARMED_AWAY
|
return STATE_ALARM_ARMED_AWAY
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
"""Send disarm command."""
|
||||||
self._alarm.disarm(code)
|
self._alarm.disarm(code)
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
"""Send arm home command."""
|
||||||
self._alarm.arm('home')
|
self._alarm.arm('home')
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
"""Send arm away command."""
|
||||||
self._alarm.arm('auto')
|
self._alarm.arm('auto')
|
||||||
|
|
||||||
def alarm_trigger(self, code=None):
|
def alarm_trigger(self, code=None):
|
||||||
""" Alarm trigger command. """
|
"""Alarm trigger command."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
"""
|
"""
|
||||||
homeassistant.components.alarm_control_panel.verisure
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Interfaces with Verisure alarm control panel.
|
Interfaces with Verisure alarm control panel.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/verisure/
|
https://home-assistant.io/components/alarm_control_panel.verisure/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -19,8 +17,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Verisure platform. """
|
"""Setup the Verisure platform."""
|
||||||
|
|
||||||
alarms = []
|
alarms = []
|
||||||
if int(hub.config.get('alarm', '1')):
|
if int(hub.config.get('alarm', '1')):
|
||||||
hub.update_alarms()
|
hub.update_alarms()
|
||||||
|
@ -33,8 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
class VerisureAlarm(alarm.AlarmControlPanel):
|
class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
""" Represents a Verisure alarm status. """
|
"""Represents a Verisure alarm status."""
|
||||||
|
|
||||||
def __init__(self, device_id):
|
def __init__(self, device_id):
|
||||||
self._id = device_id
|
self._id = device_id
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
|
@ -42,21 +38,21 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the device. """
|
"""Returns the name of the device."""
|
||||||
return 'Alarm {}'.format(self._id)
|
return 'Alarm {}'.format(self._id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
"""Returns the state of the device."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
""" code format as regex """
|
"""Code format as regex."""
|
||||||
return '^\\d{%s}$' % self._digits
|
return '^\\d{%s}$' % self._digits
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
""" Update alarm status """
|
"""Update alarm status."""
|
||||||
hub.update_alarms()
|
hub.update_alarms()
|
||||||
|
|
||||||
if hub.alarm_status[self._id].status == 'unarmed':
|
if hub.alarm_status[self._id].status == 'unarmed':
|
||||||
|
@ -71,21 +67,21 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
hub.alarm_status[self._id].status)
|
hub.alarm_status[self._id].status)
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
"""Send disarm command."""
|
||||||
hub.my_pages.alarm.set(code, 'DISARMED')
|
hub.my_pages.alarm.set(code, 'DISARMED')
|
||||||
_LOGGER.info('verisure alarm disarming')
|
_LOGGER.info('verisure alarm disarming')
|
||||||
hub.my_pages.alarm.wait_while_pending()
|
hub.my_pages.alarm.wait_while_pending()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
"""Send arm home command."""
|
||||||
hub.my_pages.alarm.set(code, 'ARMED_HOME')
|
hub.my_pages.alarm.set(code, 'ARMED_HOME')
|
||||||
_LOGGER.info('verisure alarm arming home')
|
_LOGGER.info('verisure alarm arming home')
|
||||||
hub.my_pages.alarm.wait_while_pending()
|
hub.my_pages.alarm.wait_while_pending()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
"""Send arm away command."""
|
||||||
hub.my_pages.alarm.set(code, 'ARMED_AWAY')
|
hub.my_pages.alarm.set(code, 'ARMED_AWAY')
|
||||||
_LOGGER.info('verisure alarm arming away')
|
_LOGGER.info('verisure alarm arming away')
|
||||||
hub.my_pages.alarm.wait_while_pending()
|
hub.my_pages.alarm.wait_while_pending()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue