From df6a5652541c25f669cc01312a25fa62ffd1ba5d Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Wed, 28 Feb 2024 05:25:16 +0100 Subject: [PATCH] Call service only on touch release Solves #1340 Solves #1822 --- esphome/nspanel_esphome_core.yaml | 30 ++++++++++++++++-------------- nspanel_blueprint.yaml | 7 +------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index 20b0d8a..f11469b 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -843,20 +843,22 @@ display: lambda: |- if (not id(is_uploading_tft)) { timer_reset_all->execute(page_names[page_id]); - switch (page_id) { - case 10: // light - switch (component_id) { - case 34: // power_button - ha_call_service->execute("light.toggle", "", "", detailed_entity->state.c_str()); - break; - } - break; - case 22: // fan - switch (component_id) { - case 17: // bt_oscillate - ha_call_service->execute("fan.oscillate", "", "", detailed_entity->state.c_str()); - break; - } + if (!touch_event) { // Release touch only + switch (page_id) { + case 10: // light + switch (component_id) { + case 34: // power_button + ha_call_service->execute("light.toggle", "", "", detailed_entity->state.c_str()); + break; + } + break; + case 22: // fan + switch (component_id) { + case 17: // bt_oscillate + ha_call_service->execute("fan.oscillate", "", "", detailed_entity->state.c_str()); + break; + } + } } } diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index b3da0cc..4e3cb25 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -7796,14 +7796,9 @@ action: conditions: - '{{ nspanel_event.service == "fan.oscillate" }}' sequence: - - variables: - action: > - {{ - (not state_attr(nspanel_event.entity, "oscillating") | default(true)) - }} - service: fan.oscillate data: - oscillating: '{{ action }}' + oscillating: '{{ not (state_attr(nspanel_event.entity, "oscillating") | default(true)) }}' target: entity_id: '{{ nspanel_event.entity }}' continue_on_error: true