From 6f4ef58d2bcee185eb2d010b04cece7b9577ca5e Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 11 Nov 2023 11:19:25 +0100 Subject: [PATCH] Button to trigger automation Changing behavior on button for automation from enabling/disabling to trigger the automation. Solves #1249 --- ReleaseNotes.md | 17 ++++++----- nspanel_blueprint.yaml | 68 +++++++++++++++++++++++------------------- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index d86de6b..b43a572 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -32,11 +32,12 @@ Since in this update lots of input to the blueprint changed, we highly recommend   ## Breaking changes -1. Home Assistant 2023.9.0 or later is now required -This is necessary in order to support the new [Weather Forecast Service](https://www.home-assistant.io/blog/2023/09/06/release-20239/#weather-forecast-service). -The legacy forecast based on attributes will be deprecated in Home Assistant on the begining of 2024. -2.The following components are now deprecated: +1. Home Assistant 2023.9.0 or later is now required +
This is necessary in order to support the new [Weather Forecast Service](https://www.home-assistant.io/blog/2023/09/06/release-20239/#weather-forecast-service). +
The legacy forecast based on attributes will be deprecated in Home Assistant on the begining of 2024. + +2. The following components are now deprecated: - Buttons: - Exit reparse (`button.xxxxx_exit_reparse`) - It shouldn't be necessary with the new TFT upload engine - Services: @@ -66,13 +67,15 @@ packages: ``` 3. Very long press on hardware buttons -If you have a custom automation using very long hold (more than 15s) of hardware buttons it may fail as now the panel will restart with button hold for 15s. +
If you have a custom automation using very long hold (more than 15s) of hardware buttons it may fail as now the panel will restart with button hold for 15s. 4. Logger via UART is disable -You can add it back as a [customization](https://github.com/Blackymas/NSPanel_HA_Blueprint/wiki/%28EN%29-Customization/_edit#logger-via-uart). - +
You can add it back as a [customization](https://github.com/Blackymas/NSPanel_HA_Blueprint/wiki/%28EN%29-Customization/_edit#logger-via-uart). 5. Service `notification_show` parameter `text` was renamed to `message` to support ESPHome 2023.11.0. +6. Buttons now will run an automation +
On the previous versions, a button with an automation will enable or disable the automation. Now the button will trigger the automation. +
If you want the legacy behavior, please create a script to enable/disable the automation and assign this to your button. 😉   ## Overview of noteworthy changes 1. New Upload TFT engine diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index ea190ed..2215469 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -3665,29 +3665,29 @@ variables: wake_up: 'esphome.{{ nspanel_name }}_wake_up' icon: domain: - automation: "\uF6FC" #F6FC - binary_sensor: "\uE7C0" #E7C0 - button: "\uED76" #ED76 - climate: "\uE392" #E392 - cover: "\uE0AB" #E0AB - fan: "\uE20F" #E20F - input_boolean: "\uEA19" #EA19 - input_button: "\uF2A7" #F2A7 + automation: "\uE6A8" #mdi:robot + binary_sensor: "\uE7C0" #mdi:dip-switch + button: "\uED76" #mdi:gesture-tap-hold + climate: "\uE392" #mdi:thermostat + cover: "\uE0AB" #mdi:blinds + fan: "\uE20F" #mdi:fan + input_boolean: "\uEA19" #mdi:toggle-switch-outline + input_button: "\uF2A7" #mdi:gesture-tap-button light: "\uE334" #E334 media_player: "\uE117" # mdi:cast - person: "\uE003" #E003 - scene: "\uEE0B" #EE0B - script: "\uF45D" #F45D - switch: "\uE97D" #E97D - unknown: '{{ all_icons.unknown }}' #"\uE027" #E027 + person: "\uE003" #mdi:account + scene: "\uEE0B" #mdi:palette-outline + script: "\uF45D" #mdi:cog-refresh + switch: "\uE97D" #mdi:light-switch + unknown: "\uE027" #mdi:alert-circle weather: - lightning: "\uE592" #E592 - protect: "\uF05C" #F05C - rain: "\uE595" #E595 - sun: "\uE5A7" #E5A7 - wind: "\uE59C" #E59C - gauge: "\uE299" #E299 - unknown: '{{ all_icons.unknown }}' #"\uE2D5" + lightning: "\uE592" #mdi:weather-lightning + protect: "\uF05C" #mdi:shield-sun + rain: "\uE595" #mdi:weather-pouring + sun: "\uE5A7" #mdi:white-balance-sunny + wind: "\uE59C" #mdi:weather-windy + gauge: "\uE299" #mdi:gauge + unknown: "\uE027" #mdi:alert-circle pic: button: "off": "35" @@ -7596,17 +7596,17 @@ action: btn_pic: > # Button pic (backgroun color): GRAY/WHITE {{ nextion.pic.button.on - if current_entity_state in ["on", "open", "opening", "home", "playing"] + if (current_entity_state in ["on", "open", "opening", "home", "playing"] and item_domain not in ["automation"]) or (item_domain == "climate" and current_entity_state != "off") - or (item_domain in ["button","input_button","scene"] and trigger.id is match "current_state_entity") + or (item_domain in ["button","input_button","scene","automation"] and trigger.id is match "current_state_entity") else nextion.pic.button.off }} btn_bg: > # Background color for button's icon and texts {{ nextion.color.white - if current_entity_state in ["on", "open", "opening", "home", "playing"] + if (current_entity_state in ["on", "open", "opening", "home", "playing"] and item_domain not in ["automation"]) or (item_domain == "climate" and current_entity_state != "off") - or (item_domain in ["button","input_button","scene"] and trigger.id is match "current_state_entity") + or (item_domain in ["button","input_button","scene","automation"] and trigger.id is match "current_state_entity") else nextion.color.grey_dark }} btn_icon_font: > # Foreground color for icon @@ -7627,9 +7627,9 @@ action: }} {% elif current_entity_state in ["off", "closed", "closing"] or (item_domain == "person" and current_entity_state != "home") %} {{ nextion.color.grey_light }} - {% elif item_domain in ["button", "input_button", "scene"] and trigger.id is match "current_state_entity" %} + {% elif item_domain in ["button", "input_button", "scene", "automation"] and trigger.id is match "current_state_entity" %} {{ [ repeat.item.icon_color_rgb ] if is_number(repeat.item.icon_color_rgb) else repeat.item.icon_color_rgb }} - {% elif item_domain in ["button", "input_button", "scene"] %} + {% elif item_domain in ["button", "input_button", "scene", "automation"] %} {{ nextion.color.grey_light }} {% elif current_entity_state in ["on", "open", "opening", "home"] or (item_domain == "climate" and current_entity_state != "off") %} {{ [ repeat.item.icon_color_rgb ] if is_number(repeat.item.icon_color_rgb) else repeat.item.icon_color_rgb }} @@ -7639,9 +7639,9 @@ action: {% if not current_entity_state_available %}{{ nextion.color.white }} {% elif current_entity_state in ["off", "closed", "closing"] or (item_domain == "person" and current_entity_state != "home") %} {{ nextion.color.white }} - {% elif item_domain in ["button", "input_button", "scene"] and trigger.id is match "current_state_entity" %} + {% elif item_domain in ["button", "input_button", "scene", "automation"] and trigger.id is match "current_state_entity" %} {{ nextion.color.grey_dark }} - {% elif item_domain in ["button", "input_button", "scene"] %} + {% elif item_domain in ["button", "input_button", "scene", "automation"] %} {{ nextion.color.white }} {% elif current_entity_state in ["on", "open", "opening", "home", "playing"] or (item_domain == "climate" and current_entity_state != "off") %} {{ nextion.color.grey_dark }} @@ -7707,7 +7707,11 @@ action: #btn_confirm: '{{ repeat.item.confirm }}' #entity: '{{ repeat.item.entity }}' continue_on_error: true - - if: '{{ item_domain in ["button","input_button","scene"] and trigger.id is match "current_state_entity" }}' + - if: > + {{ + (item_domain in ["button","input_button","scene"] and trigger.id is match "current_state_entity") + or item_domain in ["automation"] + }} then: - delay: milliseconds: 800 @@ -7722,7 +7726,7 @@ action: btn_icon: '{{ btn_icon }}' btn_label: '{{ btn_label }}' btn_bri_txt: '{{ btn_bri_txt }}' - btn_confirm: '{{ repeat.item.confirm }}' + #btn_confirm: '{{ repeat.item.confirm }}' #entity: '{{ repeat.item.entity }}' continue_on_error: true ###### SHOW All component when page loading done ##### @@ -8929,8 +8933,10 @@ action: - service: > {% if entity_domain in ["cover"] and states(last_click_button.entity) in ["opening", "closing"] and state_attr(last_click_button.entity, "supported_features") | int(0) | bitwise_and(4) == 0 %} {{ entity_domain }}.stop_cover - {% elif entity_domain in ["light", "switch", "cover", "input_boolean", "automation", "fan"] %} + {% elif entity_domain in ["light", "switch", "cover", "input_boolean", "fan"] %} {{ entity_domain }}.toggle + {% elif entity_domain in ["automation"] %} + {{ entity_domain }}.trigger {% elif entity_domain in ["button", "input_button"] %} {{ entity_domain }}.press {% elif entity_domain in ["scene", "script"] %}