Browse Source

turn off on long press

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

16
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:
- min_length: 400ms
max_length: 3000ms
then: then:
- light.turn_off: ledstring
- then:
- lambda: | - lambda: |
std::string current = id(ledstring).get_effect_name();
std::vector<LightEffect *> effects = id(ledstring).get_effects(); 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++) { for(int i=0; i<effects.size(); i++) {
if(effects[i]->get_name().compare(current) == 0) { if(effects[i]->get_name().compare(current) == 0) {
auto call = id(ledstring).turn_on(); next = effects[(i+1) % effects.size()]->get_name();
call.set_effect(effects[(i+1) % effects.size()]->get_name());
call.perform();
} }
} }
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