Browse Source

turn off on long press

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

30
ledstring.yml

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

Loading…
Cancel
Save