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

@@ -14,6 +14,12 @@
substitutions: substitutions:
invalid_cooldown: 100ms invalid_cooldown: 100ms
BUTTON_ACTION_NONE_TEXT: "None"
BUTTON_1_ACTION_TEXT: "Relay 1 (toggle)"
BUTTON_2_ACTION_TEXT: "Relay 2 (toggle)"
BUTTON_3_ACTION_TEXT: "Relay 3 (toggle)"
BUTTON_4_ACTION_TEXT: "Relay 4 (toggle)"
binary_sensor: binary_sensor:
- id: bs_button_1 - id: bs_button_1
name: Button 1 name: Button 1
@@ -232,8 +238,9 @@ select:
name: Button 1 action name: Button 1 action
platform: template platform: template
options: options:
- "None" - "${BUTTON_ACTION_NONE_TEXT}"
- "Relay 1 (toggle)" - "${BUTTON_1_ACTION_TEXT}"
initial_option: "${BUTTON_1_ACTION_TEXT}"
optimistic: true optimistic: true
restore_value: true restore_value: true
internal: true internal: true
@@ -245,23 +252,26 @@ select:
name: Button 2 action name: Button 2 action
platform: template platform: template
options: options:
- "None" - "${BUTTON_ACTION_NONE_TEXT}"
- "Relay 2 (toggle)" - "${BUTTON_2_ACTION_TEXT}"
initial_option: "${BUTTON_2_ACTION_TEXT}"
<<: *button_select_action_base <<: *button_select_action_base
- id: sl_button_3_action - id: sl_button_3_action
name: Button 3 action name: Button 3 action
platform: template platform: template
options: options:
- "None" - "${BUTTON_ACTION_NONE_TEXT}"
- "Relay 3 (toggle)" - "${BUTTON_3_ACTION_TEXT}"
initial_option: "${BUTTON_3_ACTION_TEXT}"
<<: *button_select_action_base <<: *button_select_action_base
- id: sl_button_4_action - id: sl_button_4_action
name: Button 4 action name: Button 4 action
platform: template platform: template
options: options:
- "None" - "${BUTTON_ACTION_NONE_TEXT}"
- "Relay 4 (toggle)" - "${BUTTON_4_ACTION_TEXT}"
initial_option: "${BUTTON_4_ACTION_TEXT}"
<<: *button_select_action_base <<: *button_select_action_base
... ...

View File

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