Browse Source

cycle through effects

master
Fr3deric 5 years ago
parent
commit
cd33006e8c
  1. 26
      ledstring.yml

26
ledstring.yml

@ -33,22 +33,16 @@ binary_sensor: @@ -33,22 +33,16 @@ binary_sensor:
name: "Button"
on_click:
then:
- switch.toggle:
id: ledstring_switch
switch:
- platform: template
optimistic: True
id: ledstring_switch
name: "LED String Switch"
turn_on_action:
- light.turn_on:
id: ledstring
brightness: 70%
effect: rainbow
turn_off_action:
- light.turn_off:
id: ledstring
- lambda: |
std::string current = id(ledstring).get_effect_name();
std::vector<LightEffect *> effects = id(ledstring).get_effects();
for(int i=0; i<effects.size(); i++) {
if(effects[i]->get_name().compare(current) == 0) {
auto call = id(ledstring).turn_on();
call.set_effect(effects[(i+1) % effects.size()]->get_name());
call.perform();
}
}
light:
- platform: neopixelbus

Loading…
Cancel
Save