Added limitlessled support for bridge v6 and RGBWW bulbs. (#5958)
* Added limitlessled support for bridge v6 and RGBWW bulbs. * Fix minor code style issue. * Updated requirements_all.txtpull/5991/head
parent
1bdd8e235a
commit
a06f89085d
|
@ -17,7 +17,7 @@ from homeassistant.components.light import (
|
|||
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, Light, PLATFORM_SCHEMA)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['limitlessled==1.0.2']
|
||||
REQUIREMENTS = ['limitlessled==1.0.3']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -25,13 +25,14 @@ CONF_BRIDGES = 'bridges'
|
|||
CONF_GROUPS = 'groups'
|
||||
CONF_NUMBER = 'number'
|
||||
CONF_VERSION = 'version'
|
||||
CONF_BRIDGE_LED = 'bridge_led'
|
||||
|
||||
DEFAULT_LED_TYPE = 'rgbw'
|
||||
DEFAULT_PORT = 8899
|
||||
DEFAULT_PORT = 5987
|
||||
DEFAULT_TRANSITION = 0
|
||||
DEFAULT_VERSION = 5
|
||||
DEFAULT_VERSION = 6
|
||||
|
||||
LED_TYPE = ['rgbw', 'white']
|
||||
LED_TYPE = ['rgbw', 'rgbww', 'white']
|
||||
|
||||
RGB_BOUNDARY = 40
|
||||
|
||||
|
@ -42,6 +43,9 @@ SUPPORT_LIMITLESSLED_WHITE = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
|
|||
SUPPORT_LIMITLESSLED_RGB = (SUPPORT_BRIGHTNESS | SUPPORT_EFFECT |
|
||||
SUPPORT_FLASH | SUPPORT_RGB_COLOR |
|
||||
SUPPORT_TRANSITION)
|
||||
SUPPORT_LIMITLESSLED_RGBWW = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
|
||||
SUPPORT_EFFECT | SUPPORT_FLASH |
|
||||
SUPPORT_RGB_COLOR | SUPPORT_TRANSITION)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_BRIDGES): vol.All(cv.ensure_list, [
|
||||
|
@ -50,6 +54,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||
vol.Optional(CONF_VERSION,
|
||||
default=DEFAULT_VERSION): cv.positive_int,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_BRIDGE_LED, default=False): cv.boolean,
|
||||
vol.Required(CONF_GROUPS): vol.All(cv.ensure_list, [
|
||||
{
|
||||
vol.Required(CONF_NAME): cv.string,
|
||||
|
@ -109,6 +114,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
group_conf.get(CONF_NAME),
|
||||
group_conf.get(CONF_TYPE, DEFAULT_LED_TYPE))
|
||||
lights.append(LimitlessLEDGroup.factory(group))
|
||||
if bridge_conf.get(CONF_BRIDGE_LED) and bridge.bridge_led is not None:
|
||||
lights.append(LimitlessLEDGroup.factory(bridge.bridge_led))
|
||||
add_devices(lights)
|
||||
|
||||
|
||||
|
@ -160,10 +167,13 @@ class LimitlessLEDGroup(Light):
|
|||
"""Produce LimitlessLEDGroup objects."""
|
||||
from limitlessled.group.rgbw import RgbwGroup
|
||||
from limitlessled.group.white import WhiteGroup
|
||||
from limitlessled.group.rgbww import RgbwwGroup
|
||||
if isinstance(group, WhiteGroup):
|
||||
return LimitlessLEDWhiteGroup(group)
|
||||
elif isinstance(group, RgbwGroup):
|
||||
return LimitlessLEDRGBWGroup(group)
|
||||
elif isinstance(group, RgbwwGroup):
|
||||
return LimitlessLEDRGBWWGroup(group)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
@ -291,6 +301,81 @@ class LimitlessLEDRGBWGroup(LimitlessLEDGroup):
|
|||
self._color = WHITE
|
||||
|
||||
|
||||
class LimitlessLEDRGBWWGroup(LimitlessLEDGroup):
|
||||
"""Representation of a LimitlessLED RGBWW group."""
|
||||
|
||||
def __init__(self, group):
|
||||
"""Initialize RGBWW group."""
|
||||
super().__init__(group)
|
||||
# Initialize group with known values.
|
||||
self.group.on = True
|
||||
self.group.white()
|
||||
self.group.temperature = 0.0
|
||||
self._color = WHITE
|
||||
self.group.brightness = 0.0
|
||||
self._brightness = _to_hass_brightness(1.0)
|
||||
self._temperature = _to_hass_temperature(self.group.temperature)
|
||||
self.group.on = False
|
||||
|
||||
@property
|
||||
def rgb_color(self):
|
||||
"""Return the color property."""
|
||||
return self._color
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
"""Return the temperature property."""
|
||||
return self._temperature
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_LIMITLESSLED_RGBWW
|
||||
|
||||
@state(True)
|
||||
def turn_on(self, transition_time, pipeline, **kwargs):
|
||||
"""Turn on (or adjust property of) a group."""
|
||||
from limitlessled.presets import COLORLOOP
|
||||
# Check arguments.
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||
if ATTR_RGB_COLOR in kwargs:
|
||||
self._color = kwargs[ATTR_RGB_COLOR]
|
||||
elif ATTR_COLOR_TEMP in kwargs:
|
||||
self._temperature = kwargs[ATTR_COLOR_TEMP]
|
||||
# White is a special case.
|
||||
if min(self._color) > 256 - RGB_BOUNDARY:
|
||||
pipeline.white()
|
||||
self._color = WHITE
|
||||
# Set up transition.
|
||||
if self._color == WHITE:
|
||||
pipeline.transition(
|
||||
transition_time,
|
||||
brightness=_from_hass_brightness(self._brightness),
|
||||
temperature=_from_hass_temperature(self._temperature)
|
||||
)
|
||||
else:
|
||||
pipeline.transition(
|
||||
transition_time,
|
||||
brightness=_from_hass_brightness(self._brightness),
|
||||
color=_from_hass_color(self._color)
|
||||
)
|
||||
# Flash.
|
||||
if ATTR_FLASH in kwargs:
|
||||
duration = 0
|
||||
if kwargs[ATTR_FLASH] == FLASH_LONG:
|
||||
duration = 1
|
||||
pipeline.flash(duration=duration)
|
||||
# Add effects.
|
||||
if ATTR_EFFECT in kwargs:
|
||||
if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP:
|
||||
self.repeating = True
|
||||
pipeline.append(COLORLOOP)
|
||||
if kwargs[ATTR_EFFECT] == EFFECT_WHITE:
|
||||
pipeline.white()
|
||||
self._color = WHITE
|
||||
|
||||
|
||||
def _from_hass_temperature(temperature):
|
||||
"""Convert Home Assistant color temperature units to percentage."""
|
||||
return (temperature - 154) / 346
|
||||
|
|
|
@ -320,7 +320,7 @@ libsoundtouch==0.1.0
|
|||
liffylights==0.9.4
|
||||
|
||||
# homeassistant.components.light.limitlessled
|
||||
limitlessled==1.0.2
|
||||
limitlessled==1.0.3
|
||||
|
||||
# homeassistant.components.media_player.liveboxplaytv
|
||||
liveboxplaytv==1.4.7
|
||||
|
|
Loading…
Reference in New Issue