From bf9b1794412724f270d24e73e526673dd7401ab7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Oct 2015 10:23:19 +0200 Subject: [PATCH 1/6] Update docstrings --- .../components/light/blinksticklight.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/light/blinksticklight.py b/homeassistant/components/light/blinksticklight.py index 364b5f030c6..3e8ba8b505d 100644 --- a/homeassistant/components/light/blinksticklight.py +++ b/homeassistant/components/light/blinksticklight.py @@ -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): From 6d3f18d09440031c27cdf44f648d93ec5bf71d21 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Oct 2015 11:08:17 +0200 Subject: [PATCH 2/6] Update docstrings --- homeassistant/components/light/rfxtrx.py | 39 +++++++----------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/light/rfxtrx.py b/homeassistant/components/light/rfxtrx.py index f76d9f7ed5b..5d6f41fe509 100644 --- a/homeassistant/components/light/rfxtrx.py +++ b/homeassistant/components/light/rfxtrx.py @@ -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) From 06cac7f9ef0a63c8db21bd016b681c9ada3aab50 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Oct 2015 11:08:32 +0200 Subject: [PATCH 3/6] Update docstrings --- homeassistant/components/rfxtrx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/rfxtrx.py b/homeassistant/components/rfxtrx.py index 79378b85e78..f6bb5c6bc71 100644 --- a/homeassistant/components/rfxtrx.py +++ b/homeassistant/components/rfxtrx.py @@ -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: From d8aefb5d55ef3c4b717bf87f84d5475f22357b0f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Oct 2015 11:08:47 +0200 Subject: [PATCH 4/6] Update docstrings --- homeassistant/components/sensor/rfxtrx.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/sensor/rfxtrx.py b/homeassistant/components/sensor/rfxtrx.py index b09d9d4a09c..1dac53015b3 100644 --- a/homeassistant/components/sensor/rfxtrx.py +++ b/homeassistant/components/sensor/rfxtrx.py @@ -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 @@ -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 From 3b7f6d3b6771644722d0983af0ba1ea641ba030c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Oct 2015 11:09:00 +0200 Subject: [PATCH 5/6] Update docstrings --- homeassistant/components/switch/rfxtrx.py | 28 +++++------------------ 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/switch/rfxtrx.py b/homeassistant/components/switch/rfxtrx.py index 98963beb769..49a788d0d04 100644 --- a/homeassistant/components/switch/rfxtrx.py +++ b/homeassistant/components/switch/rfxtrx.py @@ -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 From 9f10ab5e7ad14685caaaeae4ceaf8392e523f31a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 8 Oct 2015 11:10:05 +0200 Subject: [PATCH 6/6] Update logger output --- homeassistant/components/sensor/rfxtrx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/rfxtrx.py b/homeassistant/components/sensor/rfxtrx.py index 1dac53015b3..07912b719d2 100644 --- a/homeassistant/components/sensor/rfxtrx.py +++ b/homeassistant/components/sensor/rfxtrx.py @@ -38,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])