def enqueue(self, pipeline): """ Start a pipeline. :param pipeline: Start this pipeline. """ copied = Pipeline().append(pipeline) copied.group = self self._queue.put(copied)
def wrapper(self, **kwargs): """Wrap a group state change.""" from limitlessled.pipeline import Pipeline pipeline = Pipeline() transition_time = DEFAULT_TRANSITION if self._effect == EFFECT_COLORLOOP: self.group.stop() self._effect = None # Set transition time. if ATTR_TRANSITION in kwargs: transition_time = int(kwargs[ATTR_TRANSITION]) # Do group type-specific work. function(self, transition_time, pipeline, **kwargs) # Update state. self._is_on = new_state self.group.enqueue(pipeline) self.schedule_update_ha_state()
def wrapper(self: LimitlessLEDGroup, **kwargs: Any) -> None: """Wrap a group state change.""" # pylint: disable=protected-access pipeline = Pipeline() transition_time = DEFAULT_TRANSITION if self.effect == EFFECT_COLORLOOP: self.group.stop() self._attr_effect = None # Set transition time. if ATTR_TRANSITION in kwargs: transition_time = int(kwargs[ATTR_TRANSITION]) # Do group type-specific work. function(self, transition_time, pipeline, **kwargs) # Update state. self._attr_is_on = new_state self.group.enqueue(pipeline) self.schedule_update_ha_state()
def wrapper(self, **kwargs): """Wrap a group state change.""" from limitlessled.pipeline import Pipeline pipeline = Pipeline() transition_time = DEFAULT_TRANSITION # Stop any repeating pipeline. if self.repeating: self.repeating = False self.group.stop() # Not on and should be? Turn on. if not self.is_on and new_state is True: pipeline.on() # Set transition time. if ATTR_TRANSITION in kwargs: transition_time = int(kwargs[ATTR_TRANSITION]) # Do group type-specific work. function(self, transition_time, pipeline, **kwargs) # Update state. self._is_on = new_state self.group.enqueue(pipeline) self.schedule_update_ha_state()
import limitlessled import time import logging terminate = False def my_function(): global terminate terminate = True pass logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger() logger.info("Setup group") bridge = Bridge('192.168.178.232') gartenhaus = bridge.add_group(1, 'gartenhaus', RGB) pipeline = Pipeline().wait(10).on().wait(4).off() pipeline.callback(my_function) gartenhaus.enqueue(pipeline) logger.info("Switch on group %s", gartenhaus) while terminate == False: time.sleep(1)
""" Various preset pipelines. """ from limitlessled import Color from limitlessled.pipeline import Pipeline # Alarm (flash red). ALARM = Pipeline() \ .on() \ .color(255, 0, 0) \ .flash() \ .repeat() # Color loop (R->G->B). COLORLOOP = Pipeline() \ .on() \ .transition(10, color=Color(255, 0, 0)) \ .transition(10, color=Color(0, 255, 0)) \ .transition(10, color=Color(0, 0, 255)) \ .repeat(stages=3)