How to use the yeelight.Flow function in yeelight

To help you get started, we’ve selected a few yeelight examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / homeassistant / components / yeelight / light.py View on Github external
EFFECT_STROBE: yee_transitions.strobe,
                EFFECT_STROBE_COLOR: yee_transitions.strobe_color,
                EFFECT_ALARM: yee_transitions.alarm,
                EFFECT_POLICE: yee_transitions.police,
                EFFECT_POLICE2: yee_transitions.police2,
                EFFECT_CHRISTMAS: yee_transitions.christmas,
                EFFECT_RGB: yee_transitions.rgb,
                EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
                EFFECT_LSD: yee_transitions.lsd,
                EFFECT_SLOWDOWN: yee_transitions.slowdown,
            }

            if effect in self.custom_effects_names:
                flow = Flow(**self.custom_effects[effect])
            elif effect in effects_map:
                flow = Flow(count=0, transitions=effects_map[effect]())
            elif effect == EFFECT_FAST_RANDOM_LOOP:
                flow = Flow(
                    count=0, transitions=yee_transitions.randomloop(duration=250)
                )
            elif effect == EFFECT_WHATSAPP:
                flow = Flow(count=2, transitions=yee_transitions.pulse(37, 211, 102))
            elif effect == EFFECT_FACEBOOK:
                flow = Flow(count=2, transitions=yee_transitions.pulse(59, 89, 152))
            elif effect == EFFECT_TWITTER:
                flow = Flow(count=2, transitions=yee_transitions.pulse(0, 172, 237))

            try:
                self._bulb.start_flow(flow, light_type=self.light_type)
            except BulbException as ex:
                _LOGGER.error("Unable to set effect: %s", ex)
github skorokithakis / yeecli / yeecli / cli.py View on Github external
def temp():
    """Slowly-changing color temperature."""
    click.echo("Enjoy.")
    transitions = tr.temp()
    flow = yeelight.Flow(count=0, transitions=transitions)
    for bulb in BULBS:
        bulb.start_flow(flow)
github CodeLabClub / codelab_adapter_extensions / servers_v2 / yeelight_server.py View on Github external
def set_flow(self, index, flow_preset, count=0):
        bulb = self.get_bulb(index)
        flow = yeelight.Flow(
            count=count,
            transitions=flow_preset,
        )
        result = bulb.start_flow(flow)
        return result
github home-assistant / home-assistant / homeassistant / components / yeelight / light.py View on Github external
EFFECT_DISCO: yee_transitions.disco,
                EFFECT_TEMP: yee_transitions.temp,
                EFFECT_STROBE: yee_transitions.strobe,
                EFFECT_STROBE_COLOR: yee_transitions.strobe_color,
                EFFECT_ALARM: yee_transitions.alarm,
                EFFECT_POLICE: yee_transitions.police,
                EFFECT_POLICE2: yee_transitions.police2,
                EFFECT_CHRISTMAS: yee_transitions.christmas,
                EFFECT_RGB: yee_transitions.rgb,
                EFFECT_RANDOM_LOOP: yee_transitions.randomloop,
                EFFECT_LSD: yee_transitions.lsd,
                EFFECT_SLOWDOWN: yee_transitions.slowdown,
            }

            if effect in self.custom_effects_names:
                flow = Flow(**self.custom_effects[effect])
            elif effect in effects_map:
                flow = Flow(count=0, transitions=effects_map[effect]())
            elif effect == EFFECT_FAST_RANDOM_LOOP:
                flow = Flow(
                    count=0, transitions=yee_transitions.randomloop(duration=250)
                )
            elif effect == EFFECT_WHATSAPP:
                flow = Flow(count=2, transitions=yee_transitions.pulse(37, 211, 102))
            elif effect == EFFECT_FACEBOOK:
                flow = Flow(count=2, transitions=yee_transitions.pulse(59, 89, 152))
            elif effect == EFFECT_TWITTER:
                flow = Flow(count=2, transitions=yee_transitions.pulse(0, 172, 237))

            try:
                self._bulb.start_flow(flow, light_type=self.light_type)
            except BulbException as ex:
github skorokithakis / yeecli / yeecli / cli.py View on Github external
def slowdown():
    """Cycle with increasing transition time."""
    click.echo("Sloooooowwwwlllyyy..")
    transitions = tr.slowdown()
    flow = yeelight.Flow(count=0, transitions=transitions)
    for bulb in BULBS:
        bulb.start_flow(flow)
github skorokithakis / yeecli / yeecli / cli.py View on Github external
def redgreenblue():
    """Change from red to green to blue."""
    click.echo("Pretty colors.")
    transitions = tr.rgb()
    flow = yeelight.Flow(count=0, transitions=transitions)
    for bulb in BULBS:
        bulb.start_flow(flow)
github skorokithakis / yeecli / yeecli / cli.py View on Github external
def pulse(hex_color, pulses):
    """Pulse the bulb in a specific color."""
    red, green, blue = hex_color_to_rgb(hex_color)
    transitions = tr.pulse(red, green, blue)

    for bulb in BULBS:
        # Get the initial bulb state.
        if bulb.get_properties().get("power", "off") == "off":
            action = yeelight.Flow.actions.off
        else:
            action = yeelight.Flow.actions.recover

        bulb.start_flow(yeelight.Flow(count=pulses, action=action, transitions=transitions))
github home-assistant / home-assistant / homeassistant / components / yeelight / light.py View on Github external
duration = transition * 2

            red, green, blue = color_util.color_hs_to_RGB(*self._hs)

            transitions = list()
            transitions.append(
                RGBTransition(255, 0, 0, brightness=10, duration=duration)
            )
            transitions.append(SleepTransition(duration=transition))
            transitions.append(
                RGBTransition(
                    red, green, blue, brightness=self.brightness, duration=duration
                )
            )

            flow = Flow(count=count, transitions=transitions)
            try:
                self._bulb.start_flow(flow, light_type=self.light_type)
            except BulbException as ex:
                _LOGGER.error("Unable to set flash: %s", ex)
github skorokithakis / yeecli / yeecli / cli.py View on Github external
def christmas():
    """Christmas lights."""
    click.echo("Happy holidays.")
    transitions = tr.christmas()
    flow = yeelight.Flow(count=0, transitions=transitions)
    for bulb in BULBS:
        bulb.start_flow(flow)
github skorokithakis / yeecli / yeecli / cli.py View on Github external
def police():
    """Police lights."""
    click.echo("It's the fuzz!")
    transitions = tr.police()
    flow = yeelight.Flow(count=0, transitions=transitions)
    for bulb in BULBS:
        bulb.start_flow(flow)