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