Add link to docs and modify docstrings to match PEP257
parent
2b839de854
commit
3f82b9d6b0
|
@ -1,6 +1,4 @@
|
|||
"""
|
||||
homeassistant.components.garage_door
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Component to interface with garage doors that can be controlled remotely.
|
||||
|
||||
For more details about this component, please refer to the documentation
|
||||
|
@ -35,32 +33,32 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def is_closed(hass, entity_id=None):
|
||||
""" Returns if the garage door is closed based on the statemachine. """
|
||||
"""Returns if the garage door is closed based on the statemachine."""
|
||||
entity_id = entity_id or ENTITY_ID_ALL_GARAGE_DOORS
|
||||
return hass.states.is_state(entity_id, STATE_CLOSED)
|
||||
|
||||
|
||||
def close_door(hass, entity_id=None):
|
||||
""" Closes all or specified garage door. """
|
||||
"""Closes all or specified garage door."""
|
||||
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
|
||||
hass.services.call(DOMAIN, SERVICE_CLOSE, data)
|
||||
|
||||
|
||||
def open_door(hass, entity_id=None):
|
||||
""" Open all or specified garage door. """
|
||||
"""Open all or specified garage door."""
|
||||
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
|
||||
hass.services.call(DOMAIN, SERVICE_OPEN, data)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
""" Track states and offer events for garage door. """
|
||||
"""Track states and offer events for garage door."""
|
||||
component = EntityComponent(
|
||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, DISCOVERY_PLATFORMS,
|
||||
GROUP_NAME_ALL_GARAGE_DOORS)
|
||||
component.setup(config)
|
||||
|
||||
def handle_garage_door_service(service):
|
||||
""" Handles calls to the garage door services. """
|
||||
"""Handles calls to the garage door services."""
|
||||
target_locks = component.extract_from_service(service)
|
||||
|
||||
for item in target_locks:
|
||||
|
@ -83,25 +81,24 @@ def setup(hass, config):
|
|||
|
||||
|
||||
class GarageDoorDevice(Entity):
|
||||
""" Represents a garage door. """
|
||||
"""Represents a garage door."""
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
""" Is the garage door closed or opened. """
|
||||
"""Return true if door is closed."""
|
||||
return None
|
||||
|
||||
def close_door(self):
|
||||
""" Closes the garage door. """
|
||||
"""Closes the garage door."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def open_door(self):
|
||||
""" Opens the garage door. """
|
||||
"""Opens the garage door."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" State of the garage door. """
|
||||
"""State of the garage door."""
|
||||
closed = self.is_closed
|
||||
if closed is None:
|
||||
return STATE_UNKNOWN
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
"""
|
||||
homeassistant.components.garage_door.demo
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Demo platform that has two fake garage doors.
|
||||
Demo garage door platform that has two fake doors.
|
||||
|
||||
For more details about this platform, please refer to the documentation
|
||||
https://home-assistant.io/components/demo/
|
||||
"""
|
||||
from homeassistant.components.garage_door import GarageDoorDevice
|
||||
from homeassistant.const import STATE_CLOSED, STATE_OPEN
|
||||
|
@ -9,7 +10,7 @@ from homeassistant.const import STATE_CLOSED, STATE_OPEN
|
|||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Find and return demo garage doors. """
|
||||
"""Setup demo garage door platform."""
|
||||
add_devices_callback([
|
||||
DemoGarageDoor('Left Garage Door', STATE_CLOSED),
|
||||
DemoGarageDoor('Right Garage Door', STATE_OPEN)
|
||||
|
@ -17,32 +18,32 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
|
||||
|
||||
class DemoGarageDoor(GarageDoorDevice):
|
||||
""" Provides a demo garage door. """
|
||||
"""Provides a demo garage door."""
|
||||
def __init__(self, name, state):
|
||||
self._name = name
|
||||
self._state = state
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" No polling needed for a demo garage door. """
|
||||
"""No polling needed for a demo garage door."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the device if any. """
|
||||
"""Returns the name of the device if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
""" True if device is closed. """
|
||||
"""True if device is closed."""
|
||||
return self._state == STATE_CLOSED
|
||||
|
||||
def close_door(self, **kwargs):
|
||||
""" Close the device. """
|
||||
"""Close the device."""
|
||||
self._state = STATE_CLOSED
|
||||
self.update_ha_state()
|
||||
|
||||
def open_door(self, **kwargs):
|
||||
""" Open the device. """
|
||||
"""Open the device."""
|
||||
self._state = STATE_OPEN
|
||||
self.update_ha_state()
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
"""
|
||||
homeassistant.components.garage_door.wink
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Wink garage doors.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
|
@ -15,7 +13,7 @@ REQUIREMENTS = ['python-wink==0.6.1']
|
|||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the Wink platform. """
|
||||
"""Sets up the Wink garage door platform."""
|
||||
import pywink
|
||||
|
||||
if discovery_info is None:
|
||||
|
@ -34,34 +32,34 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
|
||||
class WinkGarageDoorDevice(GarageDoorDevice):
|
||||
""" Represents a Wink garage door. """
|
||||
"""Represents a Wink garage door."""
|
||||
|
||||
def __init__(self, wink):
|
||||
self.wink = wink
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
""" Returns the id of this wink garage door """
|
||||
"""Returns the id of this wink garage door."""
|
||||
return "{}.{}".format(self.__class__, self.wink.device_id())
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the garage door if any. """
|
||||
"""Returns the name of the garage door if any."""
|
||||
return self.wink.name()
|
||||
|
||||
def update(self):
|
||||
""" Update the state of the garage door. """
|
||||
"""Update the state of the garage door."""
|
||||
self.wink.update_state()
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
""" True if device is closed. """
|
||||
"""Returns true if door is closed."""
|
||||
return self.wink.state() == 0
|
||||
|
||||
def close_door(self):
|
||||
""" Close the device. """
|
||||
"""Closes the door."""
|
||||
self.wink.set_state(0)
|
||||
|
||||
def open_door(self):
|
||||
""" Open the device. """
|
||||
"""Open the door."""
|
||||
self.wink.set_state(1)
|
||||
|
|
Loading…
Reference in New Issue