Merge remote-tracking branch 'upstream/dev' into dev_tracker_snmp

pull/493/head
Tom Duijf 2015-10-08 10:01:24 +00:00
commit fe37a6aecc
5 changed files with 39 additions and 81 deletions

View File

@ -1,34 +1,36 @@
"""
homeassistant.components.light.blinksticklight
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Blinkstick lights.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.blinksticklight.html
"""
import logging
from blinkstick import blinkstick
import logging
from homeassistant.components.light import (Light, ATTR_RGB_COLOR)
_LOGGER = logging.getLogger(__name__)
from homeassistant.components.light import (Light, ATTR_RGB_COLOR)
REQUIREMENTS = ["blinkstick==1.1.7"]
DEPENDENCIES = []
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Add device specified by serial number """
""" Add device specified by serial number. """
stick = blinkstick.find_by_serial(config['serial'])
add_devices_callback([BlinkStickLight(stick, config['name'])])
class BlinkStickLight(Light):
""" Represents a BlinkStick light """
""" Represents a BlinkStick light. """
def __init__(self, stick, name):
""" Initialise """
self._stick = stick
self._name = name
self._serial = stick.get_serial()
@ -36,20 +38,22 @@ class BlinkStickLight(Light):
@property
def should_poll(self):
""" Polling needed. """
return True
@property
def name(self):
""" The name of the light. """
return self._name
@property
def rgb_color(self):
""" Read back the color of the light """
""" Read back the color of the light. """
return self._rgb_color
@property
def is_on(self):
""" Check whether any of the LEDs colors are non-zero """
""" Check whether any of the LEDs colors are non-zero. """
return sum(self._rgb_color) > 0
def update(self):

View File

@ -1,26 +1,10 @@
"""
homeassistant.components.light.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Rfxtrx lights.
Configuration:
To use Rfxtrx lights you will need to add the following to your
configuration.yaml file.
light:
platform: rfxtrx
devices:
ac09c4f1: Bedroom Light
ac09c4f2: Kitchen Light
ac09c4f3: Bathroom Light
*Optional*
# Automatic add new light
automatic_add: True
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for RFXtrx lights.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.rfxtrx.html
"""
import logging
import homeassistant.components.rfxtrx as rfxtrx
@ -36,7 +20,6 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup the RFXtrx platform. """
# Add light from config file
lights = []
devices = config.get('devices', None)
if devices:
@ -51,7 +34,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
add_devices_callback(lights)
def light_update(event):
""" Callback for sensor updates from the RFXtrx gateway. """
""" Callback for light updates from the RFXtrx gateway. """
if not isinstance(event.device, rfxtrxmod.LightingDevice):
return
@ -89,7 +72,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class RfxtrxLight(Light):
""" Provides a demo switch. """
""" Provides a RFXtrx light. """
def __init__(self, name, event, state):
self._name = name
self._event = event
@ -97,21 +80,21 @@ class RfxtrxLight(Light):
@property
def should_poll(self):
""" No polling needed for a demo light. """
""" No polling needed for a light. """
return False
@property
def name(self):
""" Returns the name of the device if any. """
""" Returns the name of the light if any. """
return self._name
@property
def is_on(self):
""" True if device is on. """
""" True if light is on. """
return self._state
def turn_on(self, **kwargs):
""" Turn the device on. """
""" Turn the light on. """
if hasattr(self, '_event') and self._event:
self._event.device.send_on(rfxtrx.RFXOBJECT.transport)
@ -120,7 +103,7 @@ class RfxtrxLight(Light):
self.update_ha_state()
def turn_off(self, **kwargs):
""" Turn the device off. """
""" Turn the light off. """
if hasattr(self, '_event') and self._event:
self._event.device.send_off(rfxtrx.RFXOBJECT.transport)

View File

@ -1,6 +1,6 @@
"""
homeassistant.components.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connects Home Assistant to a RFXtrx device.
Configuration:
@ -33,7 +33,7 @@ RFXOBJECT = None
def setup(hass, config):
""" Setup the Rfxtrx component. """
""" Setup the RFXtrx component. """
# Declare the Handle event
def handle_receive(event):
@ -76,7 +76,7 @@ def setup(hass, config):
def get_rfx_object(packetid):
""" return the RFXObject with the packetid"""
""" Return the RFXObject with the packetid. """
try:
import RFXtrx as rfxtrxmod
except ImportError:

View File

@ -3,21 +3,8 @@ homeassistant.components.sensor.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows sensor values from RFXtrx sensors.
Configuration:
To use the rfxtrx sensors you will need to add something like the following to
your configuration.yaml file.
sensor:
platform: rfxtrx
device: PATH_TO_DEVICE
Variables:
device
*Required
Path to your RFXtrx device.
E.g. /dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rfxtrx.html
"""
import logging
from collections import OrderedDict
@ -51,7 +38,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
if entity_id not in rfxtrx.RFX_DEVICES:
automatic_add = config.get('automatic_add', True)
if automatic_add:
_LOGGER.info("Automatic add %s rfxtrx.light", entity_id)
_LOGGER.info("Automatic add %s rfxtrx.sensor", entity_id)
new_sensor = RfxtrxSensor(event)
rfxtrx.RFX_DEVICES[entity_id] = new_sensor
add_devices_callback([new_sensor])
@ -67,7 +54,6 @@ class RfxtrxSensor(Entity):
def __init__(self, event):
self.event = event
self._unit_of_measurement = None
self._data_type = None
for data_type in DATA_TYPES:
@ -86,13 +72,14 @@ class RfxtrxSensor(Entity):
@property
def state(self):
""" Returns the state of the device. """
if self._data_type:
return self.event.values[self._data_type]
return None
@property
def name(self):
""" Get the mame of the sensor. """
""" Get the name of the sensor. """
return self._name
@property

View File

@ -1,26 +1,10 @@
"""
homeassistant.components.switch.rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Rfxtrx switch.
Configuration:
To use Rfxtrx switchs you will need to add the following to your
configuration.yaml file.
switch:
platform: rfxtrx
devices:
ac09c4f1: Bedroom Door
ac09c4f2: Kitchen Door
ac09c4f3: Bathroom Door
*Optional*
# Automatic add new switch
automatic_add: True
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for RFXtrx switches.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.rfxtrx.html
"""
import logging
import homeassistant.components.rfxtrx as rfxtrx
@ -90,7 +74,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class RfxtrxSwitch(SwitchDevice):
""" Provides a demo switch. """
""" Provides a RFXtrx switch. """
def __init__(self, name, event, state):
self._name = name
self._event = event
@ -98,7 +82,7 @@ class RfxtrxSwitch(SwitchDevice):
@property
def should_poll(self):
""" No polling needed for a demo switch. """
""" No polling needed for a RFXtrx switch. """
return False
@property