mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Fix PEP257 issues
This commit is contained in:
parent
f6bc1a4575
commit
6879e39d6c
@ -41,13 +41,13 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_locked(hass, entity_id=None):
|
||||
"""Returns if the lock is locked based on the statemachine."""
|
||||
"""Return if the lock is locked based on the statemachine."""
|
||||
entity_id = entity_id or ENTITY_ID_ALL_LOCKS
|
||||
return hass.states.is_state(entity_id, STATE_LOCKED)
|
||||
|
||||
|
||||
def lock(hass, entity_id=None, code=None):
|
||||
"""Locks all or specified locks."""
|
||||
"""Lock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
data[ATTR_CODE] = code
|
||||
@ -58,7 +58,7 @@ def lock(hass, entity_id=None, code=None):
|
||||
|
||||
|
||||
def unlock(hass, entity_id=None, code=None):
|
||||
"""Unlocks all or specified locks."""
|
||||
"""Unlock all or specified locks."""
|
||||
data = {}
|
||||
if code:
|
||||
data[ATTR_CODE] = code
|
||||
@ -76,7 +76,7 @@ def setup(hass, config):
|
||||
component.setup(config)
|
||||
|
||||
def handle_lock_service(service):
|
||||
"""Handles calls to the lock services."""
|
||||
"""Handle calls to the lock services."""
|
||||
target_locks = component.extract_from_service(service)
|
||||
|
||||
if ATTR_CODE not in service.data:
|
||||
@ -104,7 +104,8 @@ def setup(hass, config):
|
||||
|
||||
|
||||
class LockDevice(Entity):
|
||||
"""Represents a lock."""
|
||||
"""Representation of a lock."""
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
@property
|
||||
def code_format(self):
|
||||
@ -113,15 +114,15 @@ class LockDevice(Entity):
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
"""Is the lock locked or unlocked."""
|
||||
"""Return true if the lock is locked."""
|
||||
return None
|
||||
|
||||
def lock(self, **kwargs):
|
||||
"""Locks the lock."""
|
||||
"""Lock the lock."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def unlock(self, **kwargs):
|
||||
"""Unlocks the lock."""
|
||||
"""Unlock the lock."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
"""Setup the demo lock platform. """
|
||||
"""Setup the demo lock platform."""
|
||||
add_devices_callback([
|
||||
DemoLock('Front Door', STATE_LOCKED),
|
||||
DemoLock('Kitchen Door', STATE_UNLOCKED)
|
||||
@ -18,8 +18,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
|
||||
|
||||
class DemoLock(LockDevice):
|
||||
"""Provides a demo lock."""
|
||||
"""Representation of a demo lock."""
|
||||
|
||||
def __init__(self, name, state):
|
||||
"""Initialize the lock."""
|
||||
self._name = name
|
||||
self._state = state
|
||||
|
||||
|
@ -46,8 +46,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||
class MqttLock(LockDevice):
|
||||
"""Represents a lock that can be toggled using MQTT."""
|
||||
|
||||
def __init__(self, hass, name, state_topic, command_topic, qos, retain,
|
||||
payload_lock, payload_unlock, optimistic, value_template):
|
||||
"""Initialize the lock."""
|
||||
self._state = False
|
||||
self._hass = hass
|
||||
self._name = name
|
||||
|
@ -15,7 +15,7 @@ ATTR_CODE = 'code'
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Sets up the Verisure platform."""
|
||||
"""Setup the Verisure platform."""
|
||||
locks = []
|
||||
if int(hub.config.get('locks', '1')):
|
||||
hub.update_locks()
|
||||
@ -28,25 +28,27 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
class VerisureDoorlock(LockDevice):
|
||||
"""Represents a Verisure doorlock."""
|
||||
"""Representation of a Verisure doorlock."""
|
||||
|
||||
def __init__(self, device_id):
|
||||
"""Initialize the lock."""
|
||||
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 lock."""
|
||||
"""Return the name of the lock."""
|
||||
return 'Lock {}'.format(self._id)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Returns the state of the lock."""
|
||||
"""Return the state of the lock."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def code_format(self):
|
||||
"""Six digit code required."""
|
||||
"""Return the required six digit code."""
|
||||
return '^\\d{%s}$' % self._digits
|
||||
|
||||
def update(self):
|
||||
|
@ -31,8 +31,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class WinkLockDevice(LockDevice):
|
||||
"""Represents a Wink lock."""
|
||||
"""Representation of a Wink lock."""
|
||||
|
||||
def __init__(self, wink):
|
||||
"""Initialize the lock."""
|
||||
self.wink = wink
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user