I have a touchscreen (CYD) with a virtual button:
binary_sensor:
- platform: touchscreen
name: Night Mode
id: night_mode
x_min: 260
x_max: 310
y_min: 180
y_max: 230
page_id: main_page
filters:
- delayed_on_off: 10s
on_release:
then:
- if:
condition:
- lambda: |-
return id(recent_touch);
then:
- switch.toggle: day_night
- delay: 300s
- display.page.show: time_page
I also have a on_touch event like this:
touchscreen:
platform: xpt2046
spi_id: touch
cs_pin: GPIO33
interrupt_pin: GPIO36
update_interval: 50ms
threshold: 400
calibration:
x_min: 180
x_max: 3800
y_min: 240
y_max: 3860
transform:
mirror_y: false
mirror_x: false
swap_xy: true
# When the display is touched, turn on the backlight,
# store that we had a recent touch, and update the UI
on_touch:
then:
- if:
condition:
and:
- lambda: |-
return id(recent_touch);
- binary_sensor.is_off: night_mode
then:
- display.page.show_next: esp_display
- if:
condition:
display.is_displaying_page: main_page
then:
light.turn_on:
id: backlight
brightness: !lambda |-
if( isnan(id(illuminance).state) ){
return 0.2;
} else{
return (max((id(illuminance).state)*0.02, 0.2));
}
- lambda: |-
id(recent_touch) = true;
However anytime I touch the binary sensor area the touchscreen on_touch is also activated.
I tried to prevent this with - display.page.show_next: esp_display
but that doesn’t help.
How can exclude the touchbutton area from the on_touch event?