From 4d8107faf200e99d4b3b5da73c04030e5ca3787c Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 22 Dec 2024 01:15:26 +0100 Subject: [PATCH] Remove relay from binary sensor --- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 82 ++++++++----------- 1 file changed, 33 insertions(+), 49 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 79a92ce..7bb4e55 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -11,55 +11,6 @@ ##### - For normal system use, modifications to this file are NOT required. ##### #################################################################################################### --- -binary_sensor: - - id: !extend bs_button_1 - on_click: - then: - - 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: - - 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: - - 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: - - 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 type: bool @@ -159,6 +110,39 @@ script: } id(boot_initialization_relays) = true; + - id: !extend button_click_event + then: + - lambda: |- + if (id(click_counter) == 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 + switch (id(button_press_button)) { + case 1: + if (sl_button_1_action->active_index().has_value() and + sl_button_1_action->active_index().value() == 1) + sw_relay_1->toggle(); + break; + case 2: + if (sl_button_2_action->active_index().has_value() and + sl_button_2_action->active_index().value() == 1) + sw_relay_2->toggle(); + break; + case 3: + if (sl_button_3_action->active_index().has_value() and + sl_button_3_action->active_index().value() == 1) + sw_relay_3->toggle(); + break; + case 4: + if (sl_button_4_action->active_index().has_value() and + sl_button_4_action->active_index().value() == 1) + sw_relay_4->toggle(); + break; + } + } + } + - id: show_relay_status mode: restart then: