Add link to docs, new docstrings, and update docstrings

pull/1026/merge
Fabian Affolter 2016-02-01 11:47:09 +01:00
parent 8de56bc8e2
commit 395743005a
6 changed files with 46 additions and 59 deletions

View File

@ -1,8 +1,11 @@
""" """
homeassistant.components.binary_sensor.command_sensor homeassistant.components.binary_sensor.command_sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure custom shell commands to turn a value Allows to configure custom shell commands to turn a value
into a logical value for a binary sensor. into a logical value for a binary sensor.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.command/
""" """
import logging import logging
from datetime import timedelta from datetime import timedelta

View File

@ -1,9 +1,11 @@
""" """
homeassistant.components.binary_sensor.zigbee homeassistant.components.binary_sensor.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contains functionality to use a ZigBee device as a binary sensor. Contains functionality to use a ZigBee device as a binary sensor.
"""
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.zigbee/
"""
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.zigbee import ( from homeassistant.components.zigbee import (
ZigBeeDigitalIn, ZigBeeDigitalInConfig) ZigBeeDigitalIn, ZigBeeDigitalInConfig)
@ -13,9 +15,7 @@ DEPENDENCIES = ["zigbee"]
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(hass, config, add_entities, discovery_info=None):
""" """ Create and add an entity based on the configuration. """
Create and add an entity based on the configuration.
"""
add_entities([ add_entities([
ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config)) ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config))
]) ])

View File

@ -1,9 +1,11 @@
""" """
homeassistant.components.light.zigbee homeassistant.components.light.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contains functionality to use a ZigBee device as a light. Contains functionality to use a ZigBee device as a light.
"""
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.zigbee/
"""
from homeassistant.components.light import Light from homeassistant.components.light import Light
from homeassistant.components.zigbee import ( from homeassistant.components.zigbee import (
ZigBeeDigitalOut, ZigBeeDigitalOutConfig) ZigBeeDigitalOut, ZigBeeDigitalOutConfig)
@ -13,9 +15,7 @@ DEPENDENCIES = ["zigbee"]
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(hass, config, add_entities, discovery_info=None):
""" """ Create and add an entity based on the configuration. """
Create and add an entity based on the configuration.
"""
add_entities([ add_entities([
ZigBeeLight(hass, ZigBeeDigitalOutConfig(config)) ZigBeeLight(hass, ZigBeeDigitalOutConfig(config))
]) ])

View File

@ -1,9 +1,12 @@
""" """
homeassistant.components.sensor.zigbee homeassistant.components.sensor.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contains functionality to use a ZigBee device as a sensor. Contains functionality to use a ZigBee device as a sensor.
"""
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.zigbee/
"""
import logging import logging
from binascii import hexlify from binascii import hexlify
@ -36,9 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class ZigBeeTemperatureSensor(Entity): class ZigBeeTemperatureSensor(Entity):
""" """ Allows usage of an XBee Pro as a temperature sensor. """
Allows usage of an XBee Pro as a temperature sensor.
"""
def __init__(self, hass, config): def __init__(self, hass, config):
self._config = config self._config = config
self._temp = None self._temp = None

View File

@ -1,9 +1,11 @@
""" """
homeassistant.components.switch.zigbee homeassistant.components.switch.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contains functionality to use a ZigBee device as a switch. Contains functionality to use a ZigBee device as a switch.
"""
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.zigbee/
"""
from homeassistant.components.switch import SwitchDevice from homeassistant.components.switch import SwitchDevice
from homeassistant.components.zigbee import ( from homeassistant.components.zigbee import (
ZigBeeDigitalOut, ZigBeeDigitalOutConfig) ZigBeeDigitalOut, ZigBeeDigitalOutConfig)
@ -13,9 +15,7 @@ DEPENDENCIES = ["zigbee"]
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(hass, config, add_entities, discovery_info=None):
""" """ Create and add an entity based on the configuration. """
Create and add an entity based on the configuration.
"""
add_entities([ add_entities([
ZigBeeSwitch(hass, ZigBeeDigitalOutConfig(config)) ZigBeeSwitch(hass, ZigBeeDigitalOutConfig(config))
]) ])

View File

@ -1,11 +1,12 @@
""" """
homeassistant.components.zigbee homeassistant.components.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets up and provides access to a ZigBee device and contains generic entity Sets up and provides access to a ZigBee device and contains generic entity
classes. classes.
"""
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/zigbee/
"""
import logging import logging
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
@ -72,9 +73,7 @@ def setup(hass, config):
def close_serial_port(*args): def close_serial_port(*args):
""" """ Close the serial port we're using to communicate with the ZigBee. """
Close the serial port we're using to communicate with the ZigBee.
"""
DEVICE.zb.serial.close() DEVICE.zb.serial.close()
@ -89,9 +88,7 @@ class ZigBeeConfig(object):
@property @property
def name(self): def name(self):
""" """ The name given to the entity. """
The name given to the entity.
"""
return self._config["name"] return self._config["name"]
@property @property
@ -121,9 +118,7 @@ class ZigBeePinConfig(ZigBeeConfig):
""" """
@property @property
def pin(self): def pin(self):
""" """ The GPIO pin number. """
The GPIO pin number.
"""
return self._config["pin"] return self._config["pin"]
@ -193,16 +188,12 @@ class ZigBeeAnalogInConfig(ZigBeePinConfig):
""" """
@property @property
def max_voltage(self): def max_voltage(self):
""" """ The voltage at which the ADC will report its highest value. """
The voltage at which the ADC will report its highest value.
"""
return float(self._config.get("max_volts", DEFAULT_ADC_MAX_VOLTS)) return float(self._config.get("max_volts", DEFAULT_ADC_MAX_VOLTS))
class ZigBeeDigitalIn(Entity): class ZigBeeDigitalIn(Entity):
""" """ Represents a GPIO pin configured as a digital input. """
Represents a GPIO pin configured as a digital input.
"""
def __init__(self, hass, config): def __init__(self, hass, config):
self._config = config self._config = config
self._state = False self._state = False
@ -212,23 +203,21 @@ class ZigBeeDigitalIn(Entity):
@property @property
def name(self): def name(self):
""" The name of the input. """
return self._config.name return self._config.name
@property @property
def should_poll(self): def should_poll(self):
""" State of the polling, if needed. """
return self._config.should_poll return self._config.should_poll
@property @property
def is_on(self): def is_on(self):
""" """ Returns True if the Entity is on, else False. """
Returns True if the Entity is on, else False.
"""
return self._state return self._state
def update(self): def update(self):
""" """ Ask the ZigBee device what its output is set to. """
Ask the ZigBee device what its output is set to.
"""
try: try:
pin_state = DEVICE.get_gpio_pin( pin_state = DEVICE.get_gpio_pin(
self._config.pin, self._config.pin,
@ -246,9 +235,7 @@ class ZigBeeDigitalIn(Entity):
class ZigBeeDigitalOut(ZigBeeDigitalIn): class ZigBeeDigitalOut(ZigBeeDigitalIn):
""" """ Adds functionality to ZigBeeDigitalIn to control an output. """
Adds functionality to ZigBeeDigitalIn to control an output.
"""
def _set_state(self, state): def _set_state(self, state):
try: try:
DEVICE.set_gpio_pin( DEVICE.set_gpio_pin(
@ -269,22 +256,16 @@ class ZigBeeDigitalOut(ZigBeeDigitalIn):
self.update_ha_state() self.update_ha_state()
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
""" """ Set the digital output to its 'on' state. """
Set the digital output to its 'on' state.
"""
self._set_state(True) self._set_state(True)
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
""" """ Set the digital output to its 'off' state. """
Set the digital output to its 'off' state.
"""
self._set_state(False) self._set_state(False)
class ZigBeeAnalogIn(Entity): class ZigBeeAnalogIn(Entity):
""" """ Represents a GPIO pin configured as an analog input. """
Represents a GPIO pin configured as an analog input.
"""
def __init__(self, hass, config): def __init__(self, hass, config):
self._config = config self._config = config
self._value = None self._value = None
@ -294,24 +275,26 @@ class ZigBeeAnalogIn(Entity):
@property @property
def name(self): def name(self):
""" The name of the input. """
return self._config.name return self._config.name
@property @property
def should_poll(self): def should_poll(self):
""" State of the polling, if needed. """
return self._config.should_poll return self._config.should_poll
@property @property
def state(self): def state(self):
""" Returns the state of the entity. """
return self._value return self._value
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit this state is expressed in. """
return "%" return "%"
def update(self): def update(self):
""" """ Get the latest reading from the ADC. """
Get the latest reading from the ADC.
"""
try: try:
self._value = DEVICE.read_analog_pin( self._value = DEVICE.read_analog_pin(
self._config.pin, self._config.pin,