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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure custom shell commands to turn a value
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
from datetime import timedelta

View File

@ -1,9 +1,11 @@
"""
homeassistant.components.binary_sensor.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.zigbee import (
ZigBeeDigitalIn, ZigBeeDigitalInConfig)
@ -13,9 +15,7 @@ DEPENDENCIES = ["zigbee"]
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([
ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config))
])

View File

@ -1,9 +1,11 @@
"""
homeassistant.components.light.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.zigbee import (
ZigBeeDigitalOut, ZigBeeDigitalOutConfig)
@ -13,9 +15,7 @@ DEPENDENCIES = ["zigbee"]
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([
ZigBeeLight(hass, ZigBeeDigitalOutConfig(config))
])

View File

@ -1,9 +1,12 @@
"""
homeassistant.components.sensor.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
from binascii import hexlify
@ -36,9 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
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):
self._config = config
self._temp = None

View File

@ -1,9 +1,11 @@
"""
homeassistant.components.switch.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.zigbee import (
ZigBeeDigitalOut, ZigBeeDigitalOutConfig)
@ -13,9 +15,7 @@ DEPENDENCIES = ["zigbee"]
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([
ZigBeeSwitch(hass, ZigBeeDigitalOutConfig(config))
])

View File

@ -1,11 +1,12 @@
"""
homeassistant.components.zigbee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets up and provides access to a ZigBee device and contains generic entity
classes.
"""
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/zigbee/
"""
import logging
from binascii import hexlify, unhexlify
@ -72,9 +73,7 @@ def setup(hass, config):
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()
@ -89,9 +88,7 @@ class ZigBeeConfig(object):
@property
def name(self):
"""
The name given to the entity.
"""
""" The name given to the entity. """
return self._config["name"]
@property
@ -121,9 +118,7 @@ class ZigBeePinConfig(ZigBeeConfig):
"""
@property
def pin(self):
"""
The GPIO pin number.
"""
""" The GPIO pin number. """
return self._config["pin"]
@ -193,16 +188,12 @@ class ZigBeeAnalogInConfig(ZigBeePinConfig):
"""
@property
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))
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):
self._config = config
self._state = False
@ -212,23 +203,21 @@ class ZigBeeDigitalIn(Entity):
@property
def name(self):
""" The name of the input. """
return self._config.name
@property
def should_poll(self):
""" State of the polling, if needed. """
return self._config.should_poll
@property
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
def update(self):
"""
Ask the ZigBee device what its output is set to.
"""
""" Ask the ZigBee device what its output is set to. """
try:
pin_state = DEVICE.get_gpio_pin(
self._config.pin,
@ -246,9 +235,7 @@ class ZigBeeDigitalIn(Entity):
class ZigBeeDigitalOut(ZigBeeDigitalIn):
"""
Adds functionality to ZigBeeDigitalIn to control an output.
"""
""" Adds functionality to ZigBeeDigitalIn to control an output. """
def _set_state(self, state):
try:
DEVICE.set_gpio_pin(
@ -269,22 +256,16 @@ class ZigBeeDigitalOut(ZigBeeDigitalIn):
self.update_ha_state()
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)
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)
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):
self._config = config
self._value = None
@ -294,24 +275,26 @@ class ZigBeeAnalogIn(Entity):
@property
def name(self):
""" The name of the input. """
return self._config.name
@property
def should_poll(self):
""" State of the polling, if needed. """
return self._config.should_poll
@property
def state(self):
""" Returns the state of the entity. """
return self._value
@property
def unit_of_measurement(self):
""" Unit this state is expressed in. """
return "%"
def update(self):
"""
Get the latest reading from the ADC.
"""
""" Get the latest reading from the ADC. """
try:
self._value = DEVICE.read_analog_pin(
self._config.pin,