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