Update docstrings and log messages (#7526)

This commit is contained in:
Fabian Affolter 2017-05-10 12:06:57 +02:00 committed by GitHub
parent 6e6a000217
commit 71b4afb780
8 changed files with 45 additions and 43 deletions

View file

@ -31,7 +31,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Add device specified by serial number.""" """Set up Blinkstick device specified by serial number."""
from blinkstick import blinkstick from blinkstick import blinkstick
name = config.get(CONF_NAME) name = config.get(CONF_NAME)

View file

@ -20,14 +20,13 @@ _LOGGER = logging.getLogger(__name__)
CONF_SENDER_ID = 'sender_id' CONF_SENDER_ID = 'sender_id'
DEFAULT_NAME = 'EnOcean Light' DEFAULT_NAME = 'EnOcean Light'
DEPENDENCIES = ['enocean'] DEPENDENCIES = ['enocean']
SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_ID, default=[]): vol.All(cv.ensure_list, vol.Optional(CONF_ID, default=[]):
[vol.Coerce(int)]), vol.All(cv.ensure_list, [vol.Coerce(int)]),
vol.Required(CONF_SENDER_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]), vol.Required(CONF_SENDER_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}) })

View file

@ -35,26 +35,26 @@ SUPPORT_FLUX_LED_RGBW = (SUPPORT_WHITE_VALUE | SUPPORT_EFFECT |
MODE_RGB = 'rgb' MODE_RGB = 'rgb'
MODE_RGBW = 'rgbw' MODE_RGBW = 'rgbw'
# List of Supported Effects which aren't already declared in LIGHT # List of supported effects which aren't already declared in LIGHT
EFFECT_RED_FADE = "red_fade" EFFECT_RED_FADE = 'red_fade'
EFFECT_GREEN_FADE = "green_fade" EFFECT_GREEN_FADE = 'green_fade'
EFFECT_BLUE_FADE = "blue_fade" EFFECT_BLUE_FADE = 'blue_fade'
EFFECT_YELLOW_FADE = "yellow_fade" EFFECT_YELLOW_FADE = 'yellow_fade'
EFFECT_CYAN_FADE = "cyan_fade" EFFECT_CYAN_FADE = 'cyan_fade'
EFFECT_PURPLE_FADE = "purple_fade" EFFECT_PURPLE_FADE = 'purple_fade'
EFFECT_WHITE_FADE = "white_fade" EFFECT_WHITE_FADE = 'white_fade'
EFFECT_RED_GREEN_CROSS_FADE = "rg_cross_fade" EFFECT_RED_GREEN_CROSS_FADE = 'rg_cross_fade'
EFFECT_RED_BLUE_CROSS_FADE = "rb_cross_fade" EFFECT_RED_BLUE_CROSS_FADE = 'rb_cross_fade'
EFFECT_GREEN_BLUE_CROSS_FADE = "gb_cross_fade" EFFECT_GREEN_BLUE_CROSS_FADE = 'gb_cross_fade'
EFFECT_COLORSTROBE = "colorstrobe" EFFECT_COLORSTROBE = 'colorstrobe'
EFFECT_RED_STROBE = "red_strobe" EFFECT_RED_STROBE = 'red_strobe'
EFFECT_GREEN_STROBE = "green_strobe" EFFECT_GREEN_STROBE = 'green_strobe'
EFFECT_BLUE_STOBE = "blue_strobe" EFFECT_BLUE_STOBE = 'blue_strobe'
EFFECT_YELLOW_STROBE = "yellow_strobe" EFFECT_YELLOW_STROBE = 'yellow_strobe'
EFFECT_CYAN_STROBE = "cyan_strobe" EFFECT_CYAN_STROBE = 'cyan_strobe'
EFFECT_PURPLE_STROBE = "purple_strobe" EFFECT_PURPLE_STROBE = 'purple_strobe'
EFFECT_WHITE_STROBE = "white_strobe" EFFECT_WHITE_STROBE = 'white_strobe'
EFFECT_COLORJUMP = "colorjump" EFFECT_COLORJUMP = 'colorjump'
FLUX_EFFECT_LIST = [ FLUX_EFFECT_LIST = [
EFFECT_COLORLOOP, EFFECT_COLORLOOP,
@ -121,7 +121,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
ipaddr = device['ipaddr'] ipaddr = device['ipaddr']
if ipaddr in light_ips: if ipaddr in light_ips:
continue continue
device['name'] = device['id'] + " " + ipaddr device['name'] = '{} {}'.format(device['id'], ipaddr)
device[ATTR_MODE] = 'rgbw' device[ATTR_MODE] = 'rgbw'
device[CONF_PROTOCOL] = None device[CONF_PROTOCOL] = None
light = FluxLight(device) light = FluxLight(device)
@ -167,7 +167,7 @@ class FluxLight(Light):
@property @property
def unique_id(self): def unique_id(self):
"""Return the ID of this light.""" """Return the ID of this light."""
return "{}.{}".format(self.__class__, self._ipaddr) return '{}.{}'.format(self.__class__, self._ipaddr)
@property @property
def name(self): def name(self):

View file

@ -84,7 +84,7 @@ def setup_light(device_id, name, insteonhub, hass, add_devices_callback):
request_id = _CONFIGURING.pop(device_id) request_id = _CONFIGURING.pop(device_id)
configurator = get_component('configurator') configurator = get_component('configurator')
configurator.request_done(request_id) configurator.request_done(request_id)
_LOGGER.info("Device configuration done!") _LOGGER.debug("Device configuration done")
conf_lights = config_from_file(hass.config.path(INSTEON_LOCAL_LIGHTS_CONF)) conf_lights = config_from_file(hass.config.path(INSTEON_LOCAL_LIGHTS_CONF))
if device_id not in conf_lights: if device_id not in conf_lights:
@ -107,7 +107,7 @@ def config_from_file(filename, config=None):
with open(filename, 'w') as fdesc: with open(filename, 'w') as fdesc:
fdesc.write(json.dumps(config)) fdesc.write(json.dumps(config))
except IOError as error: except IOError as error:
_LOGGER.error('Saving config file failed: %s', error) _LOGGER.error("Saving config file failed: %s", error)
return False return False
return True return True
else: else:

View file

@ -1,5 +1,5 @@
""" """
Support for INSTEON lights via PowerLinc Modem. Support for Insteon lights via PowerLinc Modem.
For more details about this component, please refer to the documentation at For more details about this component, please refer to the documentation at
https://home-assistant.io/components/insteon_plm/ https://home-assistant.io/components/insteon_plm/
@ -12,16 +12,16 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
from homeassistant.loader import get_component from homeassistant.loader import get_component
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['insteon_plm'] DEPENDENCIES = ['insteon_plm']
MAX_BRIGHTNESS = 255 MAX_BRIGHTNESS = 255
_LOGGER = logging.getLogger(__name__)
@asyncio.coroutine @asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None): def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the INSTEON PLM device class for the hass platform.""" """Set up the Insteon PLM device."""
plm = hass.data['insteon_plm'] plm = hass.data['insteon_plm']
device_list = [] device_list = []
@ -30,7 +30,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
address = device.get('address_hex') address = device.get('address_hex')
dimmable = bool('dimmable' in device.get('capabilities')) dimmable = bool('dimmable' in device.get('capabilities'))
_LOGGER.info('Registered %s with light platform.', name) _LOGGER.info("Registered %s with light platform", name)
device_list.append( device_list.append(
InsteonPLMDimmerDevice(hass, plm, address, name, dimmable) InsteonPLMDimmerDevice(hass, plm, address, name, dimmable)
@ -72,14 +72,14 @@ class InsteonPLMDimmerDevice(Light):
def brightness(self): def brightness(self):
"""Return the brightness of this light between 0..255.""" """Return the brightness of this light between 0..255."""
onlevel = self._plm.get_device_attr(self._address, 'onlevel') onlevel = self._plm.get_device_attr(self._address, 'onlevel')
_LOGGER.debug('on level for %s is %s', self._address, onlevel) _LOGGER.debug("on level for %s is %s", self._address, onlevel)
return int(onlevel) return int(onlevel)
@property @property
def is_on(self): def is_on(self):
"""Return the boolean response if the node is on.""" """Return the boolean response if the node is on."""
onlevel = self._plm.get_device_attr(self._address, 'onlevel') onlevel = self._plm.get_device_attr(self._address, 'onlevel')
_LOGGER.debug('on level for %s is %s', self._address, onlevel) _LOGGER.debug("on level for %s is %s", self._address, onlevel)
return bool(onlevel) return bool(onlevel)
@property @property
@ -101,7 +101,7 @@ class InsteonPLMDimmerDevice(Light):
@callback @callback
def async_light_update(self, message): def async_light_update(self, message):
"""Receive notification from transport that new data exists.""" """Receive notification from transport that new data exists."""
_LOGGER.info('Received update calback from PLM for %s', self._address) _LOGGER.info("Received update calback from PLM for %s", self._address)
self._hass.async_add_job(self.async_update_ha_state()) self._hass.async_add_job(self.async_update_ha_state())
@asyncio.coroutine @asyncio.coroutine

View file

@ -24,13 +24,12 @@ def setup_platform(hass, config: ConfigType,
add_devices: Callable[[list], None], discovery_info=None): add_devices: Callable[[list], None], discovery_info=None):
"""Set up the ISY994 light platform.""" """Set up the ISY994 light platform."""
if isy.ISY is None or not isy.ISY.connected: if isy.ISY is None or not isy.ISY.connected:
_LOGGER.error('A connection has not been made to the ISY controller.') _LOGGER.error("A connection has not been made to the ISY controller")
return False return False
devices = [] devices = []
for node in isy.filter_nodes(isy.NODES, units=UOM, for node in isy.filter_nodes(isy.NODES, units=UOM, states=STATES):
states=STATES):
if node.dimmable or '51' in node.uom: if node.dimmable or '51' in node.uom:
devices.append(ISYLightDevice(node)) devices.append(ISYLightDevice(node))
@ -57,12 +56,12 @@ class ISYLightDevice(isy.ISYDevice, Light):
def turn_off(self, **kwargs) -> None: def turn_off(self, **kwargs) -> None:
"""Send the turn off command to the ISY994 light device.""" """Send the turn off command to the ISY994 light device."""
if not self._node.off(): if not self._node.off():
_LOGGER.debug('Unable to turn on light.') _LOGGER.debug("Unable to turn on light")
def turn_on(self, brightness=None, **kwargs) -> None: def turn_on(self, brightness=None, **kwargs) -> None:
"""Send the turn on command to the ISY994 light device.""" """Send the turn on command to the ISY994 light device."""
if not self._node.on(val=brightness): if not self._node.on(val=brightness):
_LOGGER.debug('Unable to turn on light.') _LOGGER.debug("Unable to turn on light")
@property @property
def supported_features(self): def supported_features(self):

View file

@ -4,7 +4,6 @@ Support for LimitlessLED bulbs.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.limitlessled/ https://home-assistant.io/components/light.limitlessled/
""" """
import logging import logging
import voluptuous as vol import voluptuous as vol

View file

@ -1,4 +1,9 @@
"""Support for the IKEA Tradfri platform.""" """
Support for the IKEA Tradfri platform.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.tradfri/
"""
import logging import logging
from homeassistant.components.light import ( from homeassistant.components.light import (