diff --git a/homeassistant/components/light/blinksticklight.py b/homeassistant/components/light/blinksticklight.py index 627097d47b9..700840fb4bd 100644 --- a/homeassistant/components/light/blinksticklight.py +++ b/homeassistant/components/light/blinksticklight.py @@ -8,14 +8,19 @@ import logging import voluptuous as vol -from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR, - Light, PLATFORM_SCHEMA) +from homeassistant.components.light import ( + ATTR_RGB_COLOR, SUPPORT_RGB_COLOR, Light, PLATFORM_SCHEMA) from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv +REQUIREMENTS = ['blinkstick==1.1.8'] + +_LOGGER = logging.getLogger(__name__) + CONF_SERIAL = 'serial' + DEFAULT_NAME = 'Blinkstick' -REQUIREMENTS = ["blinkstick==1.1.8"] + SUPPORT_BLINKSTICK = SUPPORT_RGB_COLOR PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @@ -23,8 +28,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) -_LOGGER = logging.getLogger(__name__) - # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/light/enocean.py b/homeassistant/components/light/enocean.py index 772cb55c4e4..ce65d8cc041 100644 --- a/homeassistant/components/light/enocean.py +++ b/homeassistant/components/light/enocean.py @@ -17,10 +17,12 @@ import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) -DEPENDENCIES = ['enocean'] -DEFAULT_NAME = 'EnOcean Light' CONF_SENDER_ID = 'sender_id' +DEFAULT_NAME = 'EnOcean Light' + +DEPENDENCIES = ['enocean'] + SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @@ -50,7 +52,7 @@ class EnOceanLight(enocean.EnOceanDevice, Light): self._sender_id = sender_id self.dev_id = dev_id self._devname = devname - self.stype = "dimmer" + self.stype = 'dimmer' @property def name(self): diff --git a/homeassistant/components/light/flux_led.py b/homeassistant/components/light/flux_led.py index 0d48e4c794b..5b25b86b9b9 100644 --- a/homeassistant/components/light/flux_led.py +++ b/homeassistant/components/light/flux_led.py @@ -4,56 +4,57 @@ Support for Flux lights. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.flux_led/ """ - import logging import socket import random + import voluptuous as vol -from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR, - ATTR_EFFECT, EFFECT_RANDOM, - SUPPORT_BRIGHTNESS, - SUPPORT_EFFECT, - SUPPORT_RGB_COLOR, Light) +from homeassistant.const import CONF_DEVICES, CONF_NAME +from homeassistant.components.light import ( + ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_EFFECT, EFFECT_RANDOM, + SUPPORT_BRIGHTNESS, SUPPORT_EFFECT, SUPPORT_RGB_COLOR, Light, + PLATFORM_SCHEMA) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['https://github.com/Danielhiversen/flux_led/archive/0.6.zip' '#flux_led==0.6'] _LOGGER = logging.getLogger(__name__) -DOMAIN = "flux_led" -ATTR_NAME = 'name' -DEVICE_SCHEMA = vol.Schema({ - vol.Optional(ATTR_NAME): cv.string, -}) +CONF_AUTOMATIC_ADD = 'automatic_add' -PLATFORM_SCHEMA = vol.Schema({ - vol.Required('platform'): DOMAIN, - vol.Optional('devices', default={}): {cv.string: DEVICE_SCHEMA}, - vol.Optional('automatic_add', default=False): cv.boolean, -}, extra=vol.ALLOW_EXTRA) +DOMAIN = 'flux_led' SUPPORT_FLUX_LED = (SUPPORT_BRIGHTNESS | SUPPORT_EFFECT | SUPPORT_RGB_COLOR) +DEVICE_SCHEMA = vol.Schema({ + vol.Optional(CONF_NAME): cv.string, +}) -def setup_platform(hass, config, add_devices_callback, discovery_info=None): +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ + vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}, + vol.Optional(CONF_AUTOMATIC_ADD, default=False): cv.boolean, +}) + + +def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Flux lights.""" import flux_led lights = [] light_ips = [] - for ipaddr, device_config in config["devices"].items(): + for ipaddr, device_config in config[CONF_DEVICES].items(): device = {} - device['name'] = device_config[ATTR_NAME] + device['name'] = device_config[CONF_NAME] device['ipaddr'] = ipaddr light = FluxLight(device) if light.is_valid: lights.append(light) light_ips.append(ipaddr) - if not config['automatic_add']: - add_devices_callback(lights) + if not config[CONF_AUTOMATIC_ADD]: + add_devices(lights) return # Find the bulbs on the LAN @@ -69,7 +70,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): lights.append(light) light_ips.append(ipaddr) - add_devices_callback(lights) + add_devices(lights) class FluxLight(Light): @@ -88,14 +89,13 @@ class FluxLight(Light): self._bulb = flux_led.WifiLedBulb(self._ipaddr) except socket.error: self.is_valid = False - _LOGGER.error("Failed to connect to bulb %s, %s", - self._ipaddr, self._name) + _LOGGER.error( + "Failed to connect to bulb %s, %s", self._ipaddr, self._name) @property def unique_id(self): """Return the ID of this light.""" - return "{}.{}".format( - self.__class__, self._ipaddr) + return "{}.{}".format(self.__class__, self._ipaddr) @property def name(self): diff --git a/homeassistant/components/light/homematic.py b/homeassistant/components/light/homematic.py index 3f8eb1a22a5..299791939c8 100644 --- a/homeassistant/components/light/homematic.py +++ b/homeassistant/components/light/homematic.py @@ -17,7 +17,7 @@ DEPENDENCIES = ['homematic'] SUPPORT_HOMEMATIC = SUPPORT_BRIGHTNESS -def setup_platform(hass, config, add_callback_devices, discovery_info=None): +def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Homematic light platform.""" if discovery_info is None: return @@ -25,7 +25,7 @@ def setup_platform(hass, config, add_callback_devices, discovery_info=None): return homematic.setup_hmdevice_discovery_helper( HMLight, discovery_info, - add_callback_devices + add_devices ) diff --git a/homeassistant/components/light/rfxtrx.py b/homeassistant/components/light/rfxtrx.py index f63a03c0534..623b42d77ad 100644 --- a/homeassistant/components/light/rfxtrx.py +++ b/homeassistant/components/light/rfxtrx.py @@ -19,12 +19,12 @@ PLATFORM_SCHEMA = rfxtrx.DEFAULT_SCHEMA SUPPORT_RFXTRX = SUPPORT_BRIGHTNESS -def setup_platform(hass, config, add_devices_callback, discovery_info=None): +def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the RFXtrx platform.""" import RFXtrx as rfxtrxmod lights = rfxtrx.get_devices_from_config(config, RfxtrxLight) - add_devices_callback(lights) + add_devices(lights) def light_update(event): """Callback for light updates from the RFXtrx gateway.""" @@ -34,7 +34,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): new_device = rfxtrx.get_new_device(event, config, RfxtrxLight) if new_device: - add_devices_callback([new_device]) + add_devices([new_device]) rfxtrx.apply_received_command(event) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 9e169ce4412..59b309e42aa 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -6,24 +6,23 @@ https://home-assistant.io/components/light.vera/ """ import logging -from homeassistant.components.light import (ATTR_BRIGHTNESS, - SUPPORT_BRIGHTNESS, Light) -from homeassistant.const import ( - STATE_OFF, STATE_ON) +from homeassistant.components.light import ( + ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) +from homeassistant.const import (STATE_OFF, STATE_ON) from homeassistant.components.vera import ( VeraDevice, VERA_DEVICES, VERA_CONTROLLER) -DEPENDENCIES = ['vera'] - _LOGGER = logging.getLogger(__name__) +DEPENDENCIES = ['vera'] + SUPPORT_VERA = SUPPORT_BRIGHTNESS # pylint: disable=unused-argument -def setup_platform(hass, config, add_devices_callback, discovery_info=None): +def setup_platform(hass, config, add_devices, discovery_info=None): """Setup Vera lights.""" - add_devices_callback( + add_devices( VeraLight(device, VERA_CONTROLLER) for device in VERA_DEVICES['light']) diff --git a/homeassistant/components/light/wemo.py b/homeassistant/components/light/wemo.py index e1f741f4c73..41143246931 100644 --- a/homeassistant/components/light/wemo.py +++ b/homeassistant/components/light/wemo.py @@ -25,7 +25,7 @@ SUPPORT_WEMO = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR | SUPPORT_TRANSITION | SUPPORT_XY_COLOR) -def setup_platform(hass, config, add_devices_callback, discovery_info=None): +def setup_platform(hass, config, add_devices, discovery_info=None): """Setup WeMo bridges and register connected lights.""" import pywemo.discovery as discovery @@ -35,10 +35,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): device = discovery.device_from_description(location, mac) if device: - setup_bridge(device, add_devices_callback) + setup_bridge(device, add_devices) -def setup_bridge(bridge, add_devices_callback): +def setup_bridge(bridge, add_devices): """Setup a WeMo link.""" lights = {} @@ -55,7 +55,7 @@ def setup_bridge(bridge, add_devices_callback): new_lights.append(lights[light_id]) if new_lights: - add_devices_callback(new_lights) + add_devices(new_lights) update_lights() @@ -73,7 +73,7 @@ class WemoLight(Light): def unique_id(self): """Return the ID of this light.""" deviceid = self.device.uniqueID - return "{}.{}".format(self.__class__, deviceid) + return '{}.{}'.format(self.__class__, deviceid) @property def name(self): diff --git a/homeassistant/components/light/wink.py b/homeassistant/components/light/wink.py index c41d88a9c30..5e479b8b47c 100644 --- a/homeassistant/components/light/wink.py +++ b/homeassistant/components/light/wink.py @@ -7,9 +7,9 @@ https://home-assistant.io/components/light.wink/ import logging import colorsys -from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \ - ATTR_RGB_COLOR, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, \ - SUPPORT_RGB_COLOR, Light +from homeassistant.components.light import ( + ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, SUPPORT_BRIGHTNESS, + SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, Light) from homeassistant.components.wink import WinkDevice from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.util import color as color_util @@ -21,8 +21,8 @@ REQUIREMENTS = ['python-wink==0.7.14', 'pubnub==3.8.2'] SUPPORT_WINK = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR -def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """Setup Wink lights.""" +def setup_platform(hass, config, add_devices, discovery_info=None): + """Setup the Wink lights.""" import pywink token = config.get(CONF_ACCESS_TOKEN) @@ -36,8 +36,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): elif token is not None: pywink.set_bearer_token(token) - add_devices_callback( - WinkLight(light) for light in pywink.get_bulbs()) + add_devices(WinkLight(light) for light in pywink.get_bulbs()) class WinkLight(WinkDevice, Light):