Firstly, thats for writing this config. I couldnt have done this without it. This is more of a suggestion and tell me if ive done this wrong "issue" rather than anything wrong with your config
I have noticed that the touch events for a single button are fired before a swipe event causing confusion on use. E.g if i swipe from left to right, the button press animation starts, then the swipe starts.
I have played around with you config and have managed to move the animations from on_press
into on_release
.
Effectively, on_press does nothing, and actions for led_on_touch
is moved into handle_release
. This might not be an issue with the default rainbow config, but I have a custom swipe left/right animation and split a led action between the 3 buttons and they were overlapping.
This basically, has the leds above the buttons turn on, but only if a press is detected. A swipe will run the swipe animation instead of running the touch events
Changes made
Remove on_press
action
Add swipe animation to leds_top
:
(havnt figured out how to take the variable colors into this lambda)
- addressable_lambda:
name: "Scan Right"
update_interval: 50ms
lambda: |-
static uint16_t progress = 0;
static Color normal = Color(255, 65, 206);
if (initial_run) {
progress = 0;
it.all() = Color::BLACK;
}
else {
//progress 1 led
if (progress < it.size()) {
it[progress] = normal;
progress++;
}
//When reach the end stop
else {
}
};
- addressable_lambda:
name: "Scan LEFT"
update_interval: 50ms
lambda: |-
static uint16_t progress = 0;
static Color normal = Color(255, 65, 206);
if (initial_run) {
progress = 0;
it.all() = Color::BLACK;
}
else {
//progress 1 led
if (progress < it.size()) {
it[it.size() - progress] = normal;
progress++;
}
//When reach the end stop
else {
}
};
Added more led partitions for individual top buttons:
- platform: partition
id: leds_top_left
internal: true
effects:
- addressable_rainbow:
segments:
- id: leds
from: 20
to: 22
- platform: partition
id: leds_top_middle
internal: true
effects:
- addressable_rainbow:
segments:
- id: leds
from: 22
to: 24
- platform: partition
id: leds_top_right
internal: true
effects:
- addressable_rainbow:
segments:
- id: leds
from: 24
to: 26
add to the top of handle_release
"then" section:
- if:
condition:
lambda: "return pos <= 3;"
then:
- script.execute: button_left_touch
else:
- if:
condition:
lambda: "return pos <= 7;"
then:
- script.execute: button_middle_touch
else:
- script.execute: button_right_touch
New button scripts:
- id: button_left_touch
mode: restart
then:
- light.turn_on:
id: leds_top_left
brightness: ${touch_brightness}
red: !lambda "return id(touch_color)[0]/100.0;"
green: !lambda "return id(touch_color)[1]/100.0;"
blue: !lambda "return id(touch_color)[2]/100.0;"
effect: ${touch_effect}
- id: button_middle_touch
mode: restart
then:
- light.turn_on:
id: leds_top_middle
brightness: ${touch_brightness}
red: !lambda "return id(touch_color)[0]/100.0;"
green: !lambda "return id(touch_color)[1]/100.0;"
blue: !lambda "return id(touch_color)[2]/100.0;"
effect: ${touch_effect}
- id: button_right_touch
mode: restart
then:
- light.turn_on:
id: leds_top_right
brightness: ${touch_brightness}
red: !lambda "return id(touch_color)[0]/100.0;"
green: !lambda "return id(touch_color)[1]/100.0;"
blue: !lambda "return id(touch_color)[2]/100.0;"
effect: ${touch_effect}