Do not toggle if other action is on place

Helps with #18
This commit is contained in:
Edward Firmo
2024-12-20 20:39:19 +01:00
parent da83c0749b
commit e0a5ea1cc8
2 changed files with 50 additions and 40 deletions

View File

@@ -15,50 +15,50 @@ binary_sensor:
- id: !extend bs_button_1
on_click:
then:
- lambda: |-
if (sl_button_1_action->active_index().has_value() and
sl_button_1_action->active_index().value() == 1 and
!bs_multi_touch->state and
!bs_swipe_left->state and
!bs_swipe_down->state and
!bs_swipe_right->state)
sw_relay_1->toggle();
- if:
condition:
- lambda: return sl_button_1_action->active_index().has_value();
- lambda: return sl_button_1_action->active_index().value() == 1;
- and: &button_click_no_other_click
- lambda: return not bs_multi_touch->state;
- lambda: return not bs_swipe_left->state;
- lambda: return not bs_swipe_down->state;
- lambda: return not bs_swipe_right->state;
then:
- switch.toggle: sw_relay_1
- id: !extend bs_button_2
on_click:
then:
- lambda: |-
if (sl_button_2_action->active_index().has_value() and
sl_button_2_action->active_index().value() == 1 and
!bs_multi_touch->state and
!bs_swipe_left->state and
!bs_swipe_down->state and
!bs_swipe_right->state)
sw_relay_2->toggle();
- if:
condition:
- lambda: return sl_button_2_action->active_index().has_value();
- lambda: return sl_button_2_action->active_index().value() == 1;
- and: *button_click_no_other_click
then:
- switch.toggle: sw_relay_2
- id: !extend bs_button_3
on_click:
then:
- lambda: |-
if (sl_button_3_action->active_index().has_value() and
sl_button_3_action->active_index().value() == 1 and
!bs_multi_touch->state and
!bs_swipe_left->state and
!bs_swipe_down->state and
!bs_swipe_right->state)
sw_relay_3->toggle();
- if:
condition:
- lambda: return sl_button_3_action->active_index().has_value();
- lambda: return sl_button_3_action->active_index().value() == 1;
- and: *button_click_no_other_click
then:
- switch.toggle: sw_relay_3
- id: !extend bs_button_4
on_click:
then:
- lambda: |-
if (sl_button_4_action->active_index().has_value() and
sl_button_4_action->active_index().value() == 1 and
!bs_multi_touch->state and
!bs_swipe_left->state and
!bs_swipe_down->state and
!bs_swipe_right->state)
sw_relay_4->toggle();
- if:
condition:
- lambda: return sl_button_4_action->active_index().has_value();
- lambda: return sl_button_4_action->active_index().value() == 1;
- and: *button_click_no_other_click
then:
- switch.toggle: sw_relay_4
globals:
- id: boot_initialization_relays