Ejemplo n.º 1
0
    def set_effect(self, effect) -> None:
        """Activate effect."""
        if not effect:
            return

        if effect == EFFECT_STOP:
            self._bulb.stop_flow(light_type=self.light_type)
            return

        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))
        else:
            return

        try:
            self._bulb.start_flow(flow, light_type=self.light_type)
            self._effect = effect
        except BulbException as ex:
            _LOGGER.error("Unable to set effect: %s", ex)
Ejemplo n.º 2
0
def random(duration):
    """Random colors."""
    click.echo("Random colors!")
    transitions = tr.randomloop(duration=duration)
    flow = yeelight.Flow(count=0, transitions=transitions)
    for bulb in BULBS:
        bulb.start_flow(flow)
Ejemplo n.º 3
0
    def set_effect(self, effect) -> None:
        """Activate effect."""
        if effect:
            from yeelight import (Flow, BulbException)
            from yeelight.transitions import (disco, temp, strobe, pulse,
                                              strobe_color, alarm, police,
                                              police2, christmas, rgb,
                                              randomloop, slowdown)
            if effect == EFFECT_STOP:
                self._bulb.stop_flow()
                return
            if effect == EFFECT_DISCO:
                flow = Flow(count=0, transitions=disco())
            if effect == EFFECT_TEMP:
                flow = Flow(count=0, transitions=temp())
            if effect == EFFECT_STROBE:
                flow = Flow(count=0, transitions=strobe())
            if effect == EFFECT_STROBE_COLOR:
                flow = Flow(count=0, transitions=strobe_color())
            if effect == EFFECT_ALARM:
                flow = Flow(count=0, transitions=alarm())
            if effect == EFFECT_POLICE:
                flow = Flow(count=0, transitions=police())
            if effect == EFFECT_POLICE2:
                flow = Flow(count=0, transitions=police2())
            if effect == EFFECT_CHRISTMAS:
                flow = Flow(count=0, transitions=christmas())
            if effect == EFFECT_RGB:
                flow = Flow(count=0, transitions=rgb())
            if effect == EFFECT_RANDOM_LOOP:
                flow = Flow(count=0, transitions=randomloop())
            if effect == EFFECT_FAST_RANDOM_LOOP:
                flow = Flow(count=0, transitions=randomloop(duration=250))
            if effect == EFFECT_SLOWDOWN:
                flow = Flow(count=0, transitions=slowdown())
            if effect == EFFECT_WHATSAPP:
                flow = Flow(count=2, transitions=pulse(37, 211, 102))
            if effect == EFFECT_FACEBOOK:
                flow = Flow(count=2, transitions=pulse(59, 89, 152))
            if effect == EFFECT_TWITTER:
                flow = Flow(count=2, transitions=pulse(0, 172, 237))

            try:
                self._bulb.start_flow(flow)
            except BulbException as ex:
                _LOGGER.error("Unable to set effect: %s", ex)
Ejemplo n.º 4
0
    def set_effect(self, effect) -> None:
        """Activate effect."""
        if effect:
            from yeelight import (Flow, BulbException)
            from yeelight.transitions import (disco, temp, strobe, pulse,
                                              strobe_color, alarm, police,
                                              police2, christmas, rgb,
                                              randomloop, slowdown)
            if effect == EFFECT_STOP:
                self._bulb.stop_flow()
                return
            if effect == EFFECT_DISCO:
                flow = Flow(count=0, transitions=disco())
            if effect == EFFECT_TEMP:
                flow = Flow(count=0, transitions=temp())
            if effect == EFFECT_STROBE:
                flow = Flow(count=0, transitions=strobe())
            if effect == EFFECT_STROBE_COLOR:
                flow = Flow(count=0, transitions=strobe_color())
            if effect == EFFECT_ALARM:
                flow = Flow(count=0, transitions=alarm())
            if effect == EFFECT_POLICE:
                flow = Flow(count=0, transitions=police())
            if effect == EFFECT_POLICE2:
                flow = Flow(count=0, transitions=police2())
            if effect == EFFECT_CHRISTMAS:
                flow = Flow(count=0, transitions=christmas())
            if effect == EFFECT_RGB:
                flow = Flow(count=0, transitions=rgb())
            if effect == EFFECT_RANDOM_LOOP:
                flow = Flow(count=0, transitions=randomloop())
            if effect == EFFECT_FAST_RANDOM_LOOP:
                flow = Flow(count=0, transitions=randomloop(duration=250))
            if effect == EFFECT_SLOWDOWN:
                flow = Flow(count=0, transitions=slowdown())
            if effect == EFFECT_WHATSAPP:
                flow = Flow(count=2, transitions=pulse(37, 211, 102))
            if effect == EFFECT_FACEBOOK:
                flow = Flow(count=2, transitions=pulse(59, 89, 152))
            if effect == EFFECT_TWITTER:
                flow = Flow(count=2, transitions=pulse(0, 172, 237))

            try:
                self._bulb.start_flow(flow)
            except BulbException as ex:
                _LOGGER.error("Unable to set effect: %s", ex)
Ejemplo n.º 5
0
    def set_effect(self, effect) -> None:
        """Activate effect."""
        if effect:
            from yeelight.transitions import (
                disco,
                temp,
                strobe,
                pulse,
                strobe_color,
                alarm,
                police,
                police2,
                christmas,
                rgb,
                randomloop,
                lsd,
                slowdown,
            )

            if effect == EFFECT_STOP:
                self._bulb.stop_flow(light_type=self.light_type)
                return

            effects_map = {
                EFFECT_DISCO: disco,
                EFFECT_TEMP: temp,
                EFFECT_STROBE: strobe,
                EFFECT_STROBE_COLOR: strobe_color,
                EFFECT_ALARM: alarm,
                EFFECT_POLICE: police,
                EFFECT_POLICE2: police2,
                EFFECT_CHRISTMAS: christmas,
                EFFECT_RGB: rgb,
                EFFECT_RANDOM_LOOP: randomloop,
                EFFECT_LSD: lsd,
                EFFECT_SLOWDOWN: 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=randomloop(duration=250))
            elif effect == EFFECT_WHATSAPP:
                flow = Flow(count=2, transitions=pulse(37, 211, 102))
            elif effect == EFFECT_FACEBOOK:
                flow = Flow(count=2, transitions=pulse(59, 89, 152))
            elif effect == EFFECT_TWITTER:
                flow = Flow(count=2, 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)
Ejemplo n.º 6
0
    def set_effect(self, effect) -> None:
        """Activate effect."""
        if effect:
            from yeelight import (Flow, BulbException)
            from yeelight.transitions import (disco, temp, strobe, pulse,
                                              strobe_color, alarm, police,
                                              police2, christmas, rgb,
                                              randomloop, lsd, slowdown)
            if effect == EFFECT_STOP:
                self._bulb.stop_flow()
                return

            effects_map = {
                EFFECT_DISCO: disco,
                EFFECT_TEMP: temp,
                EFFECT_STROBE: strobe,
                EFFECT_STROBE_COLOR: strobe_color,
                EFFECT_ALARM: alarm,
                EFFECT_POLICE: police,
                EFFECT_POLICE2: police2,
                EFFECT_CHRISTMAS: christmas,
                EFFECT_RGB: rgb,
                EFFECT_RANDOM_LOOP: randomloop,
                EFFECT_LSD: lsd,
                EFFECT_SLOWDOWN: 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=randomloop(duration=250))
            elif effect == EFFECT_WHATSAPP:
                flow = Flow(count=2, transitions=pulse(37, 211, 102))
            elif effect == EFFECT_FACEBOOK:
                flow = Flow(count=2, transitions=pulse(59, 89, 152))
            elif effect == EFFECT_TWITTER:
                flow = Flow(count=2, transitions=pulse(0, 172, 237))

            try:
                self._bulb.start_flow(flow)
            except BulbException as ex:
                _LOGGER.error("Unable to set effect: %s", ex)
Ejemplo n.º 7
0
from tkinter.colorchooser import *
from yeelight import Bulb, discover_bulbs, transitions, Flow
from PIL import Image
import pyautogui

listOfBulbs = []
brightness = 100
isFlow = False
preMadeTransitions = {
    'Alarm': transitions.alarm(),
    'Christmas': transitions.christmas(),
    'Disco': transitions.disco(),
    'LSD': transitions.lsd(),
    'Police': transitions.police(),
    'Police 2': transitions.police2(),
    'Random Loop': transitions.randomloop(),
    'RGB': transitions.rgb(),
    'Slowdown': transitions.slowdown(),
    'Strobe': transitions.strobe(),
    'Strobe Color': transitions.strobe_color(),
    'Temp': transitions.temp()
}


def searchForBulbs():
    global listOfBulbs
    listOfBulbs = []
    results = discover_bulbs()
    for bulb in results:
        listOfBulbs.append(Bulb(bulb.get("ip")))
    return listOfBulbs