Added Ledenet protocol support to flux_led (#5097)

* Added Ledenet protocol support to flux_led

* Made the protocol config lowercase
pull/5099/head
Brent Hughes 2016-12-28 23:21:29 -06:00 committed by Dale Higgs
parent f0b1874d2d
commit cf714f42df
2 changed files with 10 additions and 4 deletions

View File

@ -10,15 +10,15 @@ import random
import voluptuous as vol
from homeassistant.const import CONF_DEVICES, CONF_NAME
from homeassistant.const import CONF_DEVICES, CONF_NAME, CONF_PROTOCOL
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.10.zip'
'#flux_led==0.10']
REQUIREMENTS = ['https://github.com/Danielhiversen/flux_led/archive/0.11.zip'
'#flux_led==0.11']
_LOGGER = logging.getLogger(__name__)
@ -34,6 +34,8 @@ DEVICE_SCHEMA = vol.Schema({
vol.Optional(CONF_NAME): cv.string,
vol.Optional(ATTR_MODE, default='rgbw'):
vol.All(cv.string, vol.In(['rgbw', 'rgb'])),
vol.Optional(CONF_PROTOCOL, default=None):
vol.All(cv.string, vol.In(['ledenet'])),
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@ -51,6 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
device = {}
device['name'] = device_config[CONF_NAME]
device['ipaddr'] = ipaddr
device[CONF_PROTOCOL] = device_config[CONF_PROTOCOL]
device[ATTR_MODE] = device_config[ATTR_MODE]
light = FluxLight(device)
if light.is_valid:
@ -87,11 +90,14 @@ class FluxLight(Light):
self._name = device['name']
self._ipaddr = device['ipaddr']
self._protocol = device[CONF_PROTOCOL]
self._mode = device[ATTR_MODE]
self.is_valid = True
self._bulb = None
try:
self._bulb = flux_led.WifiLedBulb(self._ipaddr)
if self._protocol:
self._bulb.setProtocol(self._protocol)
except socket.error:
self.is_valid = False
_LOGGER.error(

View File

@ -178,7 +178,7 @@ hikvision==0.4
http://github.com/technicalpickles/python-nest/archive/e6c9d56a8df455d4d7746389811f2c1387e8cb33.zip#python-nest==3.0.3
# homeassistant.components.light.flux_led
https://github.com/Danielhiversen/flux_led/archive/0.10.zip#flux_led==0.10
https://github.com/Danielhiversen/flux_led/archive/0.11.zip#flux_led==0.11
# homeassistant.components.switch.tplink
https://github.com/GadgetReactor/pyHS100/archive/45fc3548882628bcde3e3d365db341849457bef2.zip#pyHS100==0.2.2