Adjust LimitlessLED properties for running effects (#14481)

This commit is contained in:
Anders Melchiorsen 2018-05-17 20:54:25 +02:00 committed by Sebastian Muszynski
parent ed3efc8712
commit 9afc2634c6

View file

@ -142,10 +142,9 @@ def state(new_state):
from limitlessled.pipeline import Pipeline from limitlessled.pipeline import Pipeline
pipeline = Pipeline() pipeline = Pipeline()
transition_time = DEFAULT_TRANSITION transition_time = DEFAULT_TRANSITION
# Stop any repeating pipeline. if self._effect == EFFECT_COLORLOOP:
if self.repeating:
self.repeating = False
self.group.stop() self.group.stop()
self._effect = None
# Set transition time. # Set transition time.
if ATTR_TRANSITION in kwargs: if ATTR_TRANSITION in kwargs:
transition_time = int(kwargs[ATTR_TRANSITION]) transition_time = int(kwargs[ATTR_TRANSITION])
@ -183,11 +182,11 @@ class LimitlessLEDGroup(Light):
self.group = group self.group = group
self.config = config self.config = config
self.repeating = False
self._is_on = False self._is_on = False
self._brightness = None self._brightness = None
self._temperature = None self._temperature = None
self._color = None self._color = None
self._effect = None
@asyncio.coroutine @asyncio.coroutine
def async_added_to_hass(self): def async_added_to_hass(self):
@ -222,6 +221,9 @@ class LimitlessLEDGroup(Light):
@property @property
def brightness(self): def brightness(self):
"""Return the brightness property.""" """Return the brightness property."""
if self._effect == EFFECT_NIGHT:
return 1
return self._brightness return self._brightness
@property @property
@ -242,6 +244,9 @@ class LimitlessLEDGroup(Light):
@property @property
def hs_color(self): def hs_color(self):
"""Return the color property.""" """Return the color property."""
if self._effect == EFFECT_NIGHT:
return None
return self._color return self._color
@property @property
@ -249,6 +254,11 @@ class LimitlessLEDGroup(Light):
"""Flag supported features.""" """Flag supported features."""
return self._supported return self._supported
@property
def effect(self):
"""Return the current effect for this light."""
return self._effect
@property @property
def effect_list(self): def effect_list(self):
"""Return the list of supported effects for this light.""" """Return the list of supported effects for this light."""
@ -270,6 +280,7 @@ class LimitlessLEDGroup(Light):
if kwargs.get(ATTR_EFFECT) == EFFECT_NIGHT: if kwargs.get(ATTR_EFFECT) == EFFECT_NIGHT:
if EFFECT_NIGHT in self._effect_list: if EFFECT_NIGHT in self._effect_list:
pipeline.night_light() pipeline.night_light()
self._effect = EFFECT_NIGHT
return return
pipeline.on() pipeline.on()
@ -314,7 +325,7 @@ class LimitlessLEDGroup(Light):
if ATTR_EFFECT in kwargs and self._effect_list: if ATTR_EFFECT in kwargs and self._effect_list:
if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP: if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP:
from limitlessled.presets import COLORLOOP from limitlessled.presets import COLORLOOP
self.repeating = True self._effect = EFFECT_COLORLOOP
pipeline.append(COLORLOOP) pipeline.append(COLORLOOP)
if kwargs[ATTR_EFFECT] == EFFECT_WHITE: if kwargs[ATTR_EFFECT] == EFFECT_WHITE:
pipeline.white() pipeline.white()