Browse Source

turn off on long press

master
Fr3deric 5 years ago
parent
commit
1b3cc197f7
  1. 30
      ledstring.yml

30
ledstring.yml

@ -31,18 +31,26 @@ binary_sensor: @@ -31,18 +31,26 @@ binary_sensor:
mode: INPUT_PULLUP
inverted: True
name: "Button"
on_click:
then:
- 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();
}
}
- min_length: 400ms
max_length: 3000ms
then:
- light.turn_off: ledstring
- then:
- lambda: |
std::vector<LightEffect *> effects = id(ledstring).get_effects();
std::string current = id(ledstring).get_effect_name();
std::string next = effects[0]->get_name();
for(int i=0; i<effects.size(); i++) {
if(effects[i]->get_name().compare(current) == 0) {
next = effects[(i+1) % effects.size()]->get_name();
}
}
auto call = id(ledstring).turn_on();
call.set_brightness(0.8);
call.set_effect(next);
call.perform();
light:
- platform: neopixelbus

Loading…
Cancel
Save