Fix PEP257 issues

This commit is contained in:
Fabian Affolter 2016-03-07 20:21:43 +01:00
parent f6bc1a4575
commit 3a4250133a
6 changed files with 32 additions and 21 deletions

View file

@ -50,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.""" """Map 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:
@ -121,7 +121,8 @@ 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):
"""An ABC for alarm control devices.""" """An abstract class 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."""

View file

@ -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 For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.alarmdotcom/ 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=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.""" """Represent an Alarm.com status."""
def __init__(self, hass, name, code, username, password): def __init__(self, hass, name, code, username, password):
"""Initialize the Alarm.com status."""
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
self._alarm = Alarmdotcom(username, password, timeout=10) self._alarm = Alarmdotcom(username, password, timeout=10)
self._hass = hass self._hass = hass
@ -56,7 +58,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
@property @property
def name(self): def name(self):
"""Returns the name of the device.""" """Return the name of the alarm."""
return self._name return self._name
@property @property
@ -66,7 +68,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
@property @property
def state(self): def state(self):
"""Returns the state of the device.""" """Return 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':

View file

@ -22,7 +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.""" """Setup the manual alarm platform."""
add_devices([ManualAlarm( add_devices([ManualAlarm(
hass, hass,
config.get('name', DEFAULT_ALARM_NAME), 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 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):
"""Initalize the manual alarm panel."""
self._state = STATE_ALARM_DISARMED self._state = STATE_ALARM_DISARMED
self._hass = hass self._hass = hass
self._name = name self._name = name
@ -58,12 +60,12 @@ class ManualAlarm(alarm.AlarmControlPanel):
@property @property
def name(self): def name(self):
"""Returns the name of the device.""" """Return 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.""" """Return 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 > \

View file

@ -24,7 +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.""" """Setup 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
@ -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=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.""" """Represent 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):
"""Initalize the MQTT alarm panel."""
self._state = STATE_UNKNOWN self._state = STATE_UNKNOWN
self._hass = hass self._hass = hass
self._name = name self._name = name
@ -81,12 +83,12 @@ class MqttAlarm(alarm.AlarmControlPanel):
@property @property
def name(self): def name(self):
"""Returns the name of the device.""" """Return 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. """ """Return the state of the device."""
return self._state return self._state
@property @property

View file

@ -30,7 +30,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class NX584Alarm(alarm.AlarmControlPanel): class NX584Alarm(alarm.AlarmControlPanel):
"""Represents the NX584-based alarm panel.""" """Represents the NX584-based alarm panel."""
def __init__(self, hass, host, name): def __init__(self, hass, host, name):
"""Initalize the nx584 alarm panel."""
from nx584 import client from nx584 import client
self._hass = hass self._hass = hass
self._host = host self._host = host
@ -48,17 +50,17 @@ class NX584Alarm(alarm.AlarmControlPanel):
@property @property
def name(self): def name(self):
"""Returns the name of the device.""" """Return 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.""" """The 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.""" """Return 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()

View file

@ -30,25 +30,27 @@ 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.""" """Represent a Verisure alarm status."""
def __init__(self, device_id): def __init__(self, device_id):
"""Initalize the Verisure alarm panel."""
self._id = device_id self._id = device_id
self._state = STATE_UNKNOWN self._state = STATE_UNKNOWN
self._digits = int(hub.config.get('code_digits', '4')) self._digits = int(hub.config.get('code_digits', '4'))
@property @property
def name(self): def name(self):
"""Returns the name of the device.""" """Return 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.""" """Return 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.""" """The code format as regex."""
return '^\\d{%s}$' % self._digits return '^\\d{%s}$' % self._digits
def update(self): def update(self):