Simplify relay handler

This commit is contained in:
Edward Firmo
2024-12-22 02:03:35 +01:00
parent fbc5cb79cc
commit be0fc353f6
2 changed files with 35 additions and 29 deletions

View File

@@ -74,7 +74,7 @@ improv_serial:
id: serial_improv
logger:
level: INFO
level: DEBUG
ota:
platform: esphome

View File

@@ -113,11 +113,19 @@ script:
- id: !extend button_click_event
then:
- lambda: |-
if (click_count == 1) { // Single click
if (!bs_multi_touch->state and
!bs_swipe_left->state and
!bs_swipe_down->state and
!bs_swipe_right->state) { // Ignore if other events are active
// Handle only single clicks
if (click_count != 1)
return;
// Ignore if other touch events are active
if (bs_multi_touch->state ||
bs_swipe_left->state ||
bs_swipe_down->state ||
bs_swipe_right->state) {
return;
}
// Toggle relay if corresponding button action is enabled
switch (button_id) {
case 1:
if (sl_button_1_action->active_index().has_value() and
@@ -140,8 +148,6 @@ script:
sw_relay_4->toggle();
break;
}
}
}
- id: show_relay_status
mode: restart