Simplify relay handler
This commit is contained in:
@@ -74,7 +74,7 @@ improv_serial:
|
|||||||
id: serial_improv
|
id: serial_improv
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: INFO
|
level: DEBUG
|
||||||
|
|
||||||
ota:
|
ota:
|
||||||
platform: esphome
|
platform: esphome
|
||||||
|
|||||||
@@ -113,11 +113,19 @@ script:
|
|||||||
- id: !extend button_click_event
|
- id: !extend button_click_event
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
if (click_count == 1) { // Single click
|
// Handle only single clicks
|
||||||
if (!bs_multi_touch->state and
|
if (click_count != 1)
|
||||||
!bs_swipe_left->state and
|
return;
|
||||||
!bs_swipe_down->state and
|
|
||||||
!bs_swipe_right->state) { // Ignore if other events are active
|
// 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) {
|
switch (button_id) {
|
||||||
case 1:
|
case 1:
|
||||||
if (sl_button_1_action->active_index().has_value() and
|
if (sl_button_1_action->active_index().has_value() and
|
||||||
@@ -140,8 +148,6 @@ script:
|
|||||||
sw_relay_4->toggle();
|
sw_relay_4->toggle();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- id: show_relay_status
|
- id: show_relay_status
|
||||||
mode: restart
|
mode: restart
|
||||||
|
|||||||
Reference in New Issue
Block a user