From 3a4250133af93d426507edf364fc91eba48193de Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 7 Mar 2016 20:21:43 +0100 Subject: [PATCH] Fix PEP257 issues --- .../components/alarm_control_panel/__init__.py | 5 +++-- .../components/alarm_control_panel/alarmdotcom.py | 10 ++++++---- homeassistant/components/alarm_control_panel/manual.py | 8 +++++--- homeassistant/components/alarm_control_panel/mqtt.py | 10 ++++++---- homeassistant/components/alarm_control_panel/nx584.py | 10 ++++++---- .../components/alarm_control_panel/verisure.py | 10 ++++++---- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index db0b66a6f48..a7032a73f60 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -50,7 +50,7 @@ def setup(hass, config): component.setup(config) def alarm_service_handler(service): - """Maps services to methods on Alarm.""" + """Map services to methods on Alarm.""" target_alarms = component.extract_from_service(service) if ATTR_CODE not in service.data: @@ -121,7 +121,8 @@ def alarm_trigger(hass, code=None, entity_id=None): # pylint: disable=no-self-use class AlarmControlPanel(Entity): - """An ABC for alarm control devices.""" + """An abstract class for alarm control devices.""" + @property def code_format(self): """Regex for code format or None if no code is required.""" diff --git a/homeassistant/components/alarm_control_panel/alarmdotcom.py b/homeassistant/components/alarm_control_panel/alarmdotcom.py index 94cc4e8453e..385cabb7d02 100644 --- a/homeassistant/components/alarm_control_panel/alarmdotcom.py +++ b/homeassistant/components/alarm_control_panel/alarmdotcom.py @@ -1,5 +1,5 @@ """ -Interfaces with Verisure alarm control panel. +Interfaces with Alarm.com alarm control panels. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.alarmdotcom/ @@ -39,8 +39,10 @@ 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.""" + """Represent an Alarm.com status.""" + def __init__(self, hass, name, code, username, password): + """Initialize the Alarm.com status.""" from pyalarmdotcom.pyalarmdotcom import Alarmdotcom self._alarm = Alarmdotcom(username, password, timeout=10) self._hass = hass @@ -56,7 +58,7 @@ class AlarmDotCom(alarm.AlarmControlPanel): @property def name(self): - """Returns the name of the device.""" + """Return the name of the alarm.""" return self._name @property @@ -66,7 +68,7 @@ class AlarmDotCom(alarm.AlarmControlPanel): @property def state(self): - """Returns the state of the device.""" + """Return the state of the device.""" if self._alarm.state == 'Disarmed': return STATE_ALARM_DISARMED elif self._alarm.state == 'Armed Stay': diff --git a/homeassistant/components/alarm_control_panel/manual.py b/homeassistant/components/alarm_control_panel/manual.py index 2a63bce7da3..3e904601638 100644 --- a/homeassistant/components/alarm_control_panel/manual.py +++ b/homeassistant/components/alarm_control_panel/manual.py @@ -22,7 +22,7 @@ DEFAULT_TRIGGER_TIME = 120 def setup_platform(hass, config, add_devices, discovery_info=None): - """Sets up the manual alarm platform.""" + """Setup the manual alarm platform.""" add_devices([ManualAlarm( hass, config.get('name', DEFAULT_ALARM_NAME), @@ -42,7 +42,9 @@ 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): + """Initalize the manual alarm panel.""" self._state = STATE_ALARM_DISARMED self._hass = hass self._name = name @@ -58,12 +60,12 @@ class ManualAlarm(alarm.AlarmControlPanel): @property def name(self): - """Returns the name of the device.""" + """Return the name of the device.""" return self._name @property def state(self): - """Returns the state of the device.""" + """Return 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 > \ diff --git a/homeassistant/components/alarm_control_panel/mqtt.py b/homeassistant/components/alarm_control_panel/mqtt.py index be64214c551..0e86e0df875 100644 --- a/homeassistant/components/alarm_control_panel/mqtt.py +++ b/homeassistant/components/alarm_control_panel/mqtt.py @@ -24,7 +24,7 @@ DEPENDENCIES = ['mqtt'] def setup_platform(hass, config, add_devices, discovery_info=None): - """Sets up the MQTT platform.""" + """Setup the MQTT platform.""" if config.get('state_topic') is None: _LOGGER.error("Missing required variable: state_topic") return False @@ -48,9 +48,11 @@ 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.""" + """Represent a MQTT alarm status.""" + def __init__(self, hass, name, state_topic, command_topic, qos, payload_disarm, payload_arm_home, payload_arm_away, code): + """Initalize the MQTT alarm panel.""" self._state = STATE_UNKNOWN self._hass = hass self._name = name @@ -81,12 +83,12 @@ class MqttAlarm(alarm.AlarmControlPanel): @property def name(self): - """Returns the name of the device.""" + """Return the name of the device.""" return self._name @property def state(self): - """ Returns the state of the device. """ + """Return the state of the device.""" return self._state @property diff --git a/homeassistant/components/alarm_control_panel/nx584.py b/homeassistant/components/alarm_control_panel/nx584.py index 1f5f46c03f7..2b3facbdb0e 100644 --- a/homeassistant/components/alarm_control_panel/nx584.py +++ b/homeassistant/components/alarm_control_panel/nx584.py @@ -29,8 +29,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class NX584Alarm(alarm.AlarmControlPanel): - """Represents the NX584-based alarm panel. """ + """Represents the NX584-based alarm panel.""" + def __init__(self, hass, host, name): + """Initalize the nx584 alarm panel.""" from nx584 import client self._hass = hass self._host = host @@ -48,17 +50,17 @@ class NX584Alarm(alarm.AlarmControlPanel): @property def name(self): - """Returns the name of the device.""" + """Return the name of the device.""" return self._name @property def code_format(self): - """Characters if code is defined.""" + """The characters if code is defined.""" return '[0-9]{4}([0-9]{2})?' @property def state(self): - """Returns the state of the device.""" + """Return the state of the device.""" try: part = self._alarm.list_partitions()[0] zones = self._alarm.list_zones() diff --git a/homeassistant/components/alarm_control_panel/verisure.py b/homeassistant/components/alarm_control_panel/verisure.py index 93414a73a5e..9bc25af3b69 100644 --- a/homeassistant/components/alarm_control_panel/verisure.py +++ b/homeassistant/components/alarm_control_panel/verisure.py @@ -30,25 +30,27 @@ def setup_platform(hass, config, add_devices, discovery_info=None): # pylint: disable=abstract-method class VerisureAlarm(alarm.AlarmControlPanel): - """Represents a Verisure alarm status.""" + """Represent a Verisure alarm status.""" + def __init__(self, device_id): + """Initalize the Verisure alarm panel.""" self._id = device_id self._state = STATE_UNKNOWN self._digits = int(hub.config.get('code_digits', '4')) @property def name(self): - """Returns the name of the device.""" + """Return the name of the device.""" return 'Alarm {}'.format(self._id) @property def state(self): - """Returns the state of the device.""" + """Return the state of the device.""" return self._state @property def code_format(self): - """Code format as regex.""" + """The code format as regex.""" return '^\\d{%s}$' % self._digits def update(self):