mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
converted majority of effects from ifs to dict map, which makes it easier to extend in the future. Also, added LSD effect! (#18656)
This commit is contained in:
parent
37327f6cbd
commit
8771f9f7dd
@ -76,6 +76,7 @@ EFFECT_CHRISTMAS = "Christmas"
|
|||||||
EFFECT_RGB = "RGB"
|
EFFECT_RGB = "RGB"
|
||||||
EFFECT_RANDOM_LOOP = "Random Loop"
|
EFFECT_RANDOM_LOOP = "Random Loop"
|
||||||
EFFECT_FAST_RANDOM_LOOP = "Fast Random Loop"
|
EFFECT_FAST_RANDOM_LOOP = "Fast Random Loop"
|
||||||
|
EFFECT_LSD = "LSD"
|
||||||
EFFECT_SLOWDOWN = "Slowdown"
|
EFFECT_SLOWDOWN = "Slowdown"
|
||||||
EFFECT_WHATSAPP = "WhatsApp"
|
EFFECT_WHATSAPP = "WhatsApp"
|
||||||
EFFECT_FACEBOOK = "Facebook"
|
EFFECT_FACEBOOK = "Facebook"
|
||||||
@ -94,6 +95,7 @@ YEELIGHT_EFFECT_LIST = [
|
|||||||
EFFECT_RGB,
|
EFFECT_RGB,
|
||||||
EFFECT_RANDOM_LOOP,
|
EFFECT_RANDOM_LOOP,
|
||||||
EFFECT_FAST_RANDOM_LOOP,
|
EFFECT_FAST_RANDOM_LOOP,
|
||||||
|
EFFECT_LSD,
|
||||||
EFFECT_SLOWDOWN,
|
EFFECT_SLOWDOWN,
|
||||||
EFFECT_WHATSAPP,
|
EFFECT_WHATSAPP,
|
||||||
EFFECT_FACEBOOK,
|
EFFECT_FACEBOOK,
|
||||||
@ -413,34 +415,30 @@ class YeelightLight(Light):
|
|||||||
from yeelight.transitions import (disco, temp, strobe, pulse,
|
from yeelight.transitions import (disco, temp, strobe, pulse,
|
||||||
strobe_color, alarm, police,
|
strobe_color, alarm, police,
|
||||||
police2, christmas, rgb,
|
police2, christmas, rgb,
|
||||||
randomloop, slowdown)
|
randomloop, lsd, slowdown)
|
||||||
if effect == EFFECT_STOP:
|
if effect == EFFECT_STOP:
|
||||||
self._bulb.stop_flow()
|
self._bulb.stop_flow()
|
||||||
return
|
return
|
||||||
if effect == EFFECT_DISCO:
|
|
||||||
flow = Flow(count=0, transitions=disco())
|
effects_map = {
|
||||||
if effect == EFFECT_TEMP:
|
EFFECT_DISCO: disco,
|
||||||
flow = Flow(count=0, transitions=temp())
|
EFFECT_TEMP: temp,
|
||||||
if effect == EFFECT_STROBE:
|
EFFECT_STROBE: strobe,
|
||||||
flow = Flow(count=0, transitions=strobe())
|
EFFECT_STROBE_COLOR: strobe_color,
|
||||||
if effect == EFFECT_STROBE_COLOR:
|
EFFECT_ALARM: alarm,
|
||||||
flow = Flow(count=0, transitions=strobe_color())
|
EFFECT_POLICE: police,
|
||||||
if effect == EFFECT_ALARM:
|
EFFECT_POLICE2: police2,
|
||||||
flow = Flow(count=0, transitions=alarm())
|
EFFECT_CHRISTMAS: christmas,
|
||||||
if effect == EFFECT_POLICE:
|
EFFECT_RGB: rgb,
|
||||||
flow = Flow(count=0, transitions=police())
|
EFFECT_RANDOM_LOOP: randomloop,
|
||||||
if effect == EFFECT_POLICE2:
|
EFFECT_LSD: lsd,
|
||||||
flow = Flow(count=0, transitions=police2())
|
EFFECT_SLOWDOWN: slowdown,
|
||||||
if effect == EFFECT_CHRISTMAS:
|
}
|
||||||
flow = Flow(count=0, transitions=christmas())
|
|
||||||
if effect == EFFECT_RGB:
|
if effect in effects_map:
|
||||||
flow = Flow(count=0, transitions=rgb())
|
flow = Flow(count=0, transitions=effects_map[effect]())
|
||||||
if effect == EFFECT_RANDOM_LOOP:
|
|
||||||
flow = Flow(count=0, transitions=randomloop())
|
|
||||||
if effect == EFFECT_FAST_RANDOM_LOOP:
|
if effect == EFFECT_FAST_RANDOM_LOOP:
|
||||||
flow = Flow(count=0, transitions=randomloop(duration=250))
|
flow = Flow(count=0, transitions=randomloop(duration=250))
|
||||||
if effect == EFFECT_SLOWDOWN:
|
|
||||||
flow = Flow(count=0, transitions=slowdown())
|
|
||||||
if effect == EFFECT_WHATSAPP:
|
if effect == EFFECT_WHATSAPP:
|
||||||
flow = Flow(count=2, transitions=pulse(37, 211, 102))
|
flow = Flow(count=2, transitions=pulse(37, 211, 102))
|
||||||
if effect == EFFECT_FACEBOOK:
|
if effect == EFFECT_FACEBOOK:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user