Add limitlessled night effect (#12567)

This commit is contained in:
Anders Melchiorsen 2018-02-21 08:08:45 +01:00 committed by Paulus Schoutsen
parent 49d410546a
commit 5ad0baf128

View file

@ -37,6 +37,8 @@ DEFAULT_FADE = False
LED_TYPE = ['rgbw', 'rgbww', 'white', 'bridge-led', 'dimmer']
EFFECT_NIGHT = 'night'
RGB_BOUNDARY = 40
WHITE = [255, 255, 255]
@ -166,12 +168,16 @@ class LimitlessLEDGroup(Light):
from limitlessled.group.rgbww import RgbwwGroup
if isinstance(group, WhiteGroup):
self._supported = SUPPORT_LIMITLESSLED_WHITE
self._effect_list = [EFFECT_NIGHT]
elif isinstance(group, DimmerGroup):
self._supported = SUPPORT_LIMITLESSLED_DIMMER
self._effect_list = []
elif isinstance(group, RgbwGroup):
self._supported = SUPPORT_LIMITLESSLED_RGB
self._effect_list = [EFFECT_COLORLOOP, EFFECT_NIGHT, EFFECT_WHITE]
elif isinstance(group, RgbwwGroup):
self._supported = SUPPORT_LIMITLESSLED_RGBWW
self._effect_list = [EFFECT_COLORLOOP, EFFECT_NIGHT, EFFECT_WHITE]
self.group = group
self.config = config
@ -231,6 +237,11 @@ class LimitlessLEDGroup(Light):
"""Flag supported features."""
return self._supported
@property
def effect_list(self):
"""Return the list of supported effects for this light."""
return self._effect_list
# pylint: disable=arguments-differ
@state(False)
def turn_off(self, transition_time, pipeline, **kwargs):
@ -243,6 +254,12 @@ class LimitlessLEDGroup(Light):
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""
# The night effect does not need a turned on light
if kwargs.get(ATTR_EFFECT) == EFFECT_NIGHT:
if EFFECT_NIGHT in self._effect_list:
pipeline.night_light()
return
pipeline.on()
# Set up transition.
@ -282,7 +299,7 @@ class LimitlessLEDGroup(Light):
pipeline.flash(duration=duration)
# Add effects.
if ATTR_EFFECT in kwargs and self._supported & SUPPORT_EFFECT:
if ATTR_EFFECT in kwargs and self._effect_list:
if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP:
from limitlessled.presets import COLORLOOP
self.repeating = True