Add link to docs and modify docstrings to match PEP257

This commit is contained in:
Fabian Affolter 2016-02-24 10:38:06 +01:00
parent 3f82b9d6b0
commit 4563c54a3e
13 changed files with 155 additions and 152 deletions

View file

@ -1,8 +1,8 @@
"""
homeassistant.components.lock.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo lock platform that has two fake locks.
Demo platform that has two fake locks.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
"""
from homeassistant.components.lock import LockDevice
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
@ -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):
""" Find and return demo locks. """
"""Setup the demo lock platform. """
add_devices_callback([
DemoLock('Front Door', STATE_LOCKED),
DemoLock('Kitchen Door', STATE_UNLOCKED)
@ -18,32 +18,32 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class DemoLock(LockDevice):
""" Provides a demo lock. """
"""Provides a demo lock."""
def __init__(self, name, state):
self._name = name
self._state = state
@property
def should_poll(self):
""" No polling needed for a demo lock. """
"""No polling needed for a demo lock."""
return False
@property
def name(self):
""" Returns the name of the device if any. """
"""Return the name of the lock if any."""
return self._name
@property
def is_locked(self):
""" True if device is locked. """
"""Return true if lock is locked."""
return self._state == STATE_LOCKED
def lock(self, **kwargs):
""" Lock the device. """
"""Lock the device."""
self._state = STATE_LOCKED
self.update_ha_state()
def unlock(self, **kwargs):
""" Unlock the device. """
"""Unlock the device."""
self._state = STATE_UNLOCKED
self.update_ha_state()