Visual feedback for stateless entities (hw button) (#725)

Implement visual feedback for stateless entities (whatever finishes with a state other than `on`, `off`, `open` and `closed`, like scenes, automations, buttons, etc.).
This extends b18f2848f4 and solves #691.
This commit is contained in:
Edward Firmo
2023-04-25 21:00:30 +02:00
committed by GitHub
parent a252ddf74e
commit 355a643ff7

View File

@@ -4558,17 +4558,17 @@ trigger:
##### Left Button - State 'left_button_state' ##### ##### Left Button - State 'left_button_state' #####
- platform: state - platform: state
entity_id: !input 'left_button_entity' entity_id: !input 'left_button_entity'
to: not_to:
- "on" - unavailable
- "off" - unknown
id: left_button_state id: left_button_state
##### Right Button - State 'right_button_state' ##### ##### Right Button - State 'right_button_state' #####
- platform: state - platform: state
entity_id: !input 'right_button_entity' entity_id: !input 'right_button_entity'
to: not_to:
- "on" - unavailable
- "off" - unknown
id: right_button_state id: right_button_state
##### Trigger - Time ################################################################################################################# ##### Trigger - Time #################################################################################################################
@@ -5715,7 +5715,7 @@ action:
- 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" }}'
then: then:
- delay: - delay:
milliseconds: '1000' milliseconds: 800
- service: '{{ nextion.commands.set_button }}' - service: '{{ nextion.commands.set_button }}'
data: data:
btn_id: '{{ repeat.item.page }}.{{ repeat.item.component }}' btn_id: '{{ repeat.item.page }}.{{ repeat.item.component }}'
@@ -7141,8 +7141,8 @@ action:
message: '{{ set_button04_icon_font }}' message: '{{ set_button04_icon_font }}'
continue_on_error: true continue_on_error: true
##### BUTTON - press ##### ##### HW BUTTON - press #####
- alias: Button - Press - alias: Hardware button - Press
conditions: conditions:
- condition: trigger - condition: trigger
id: id:
@@ -7194,14 +7194,19 @@ action:
- left_button_state - left_button_state
- right_button_state - right_button_state
- '{{ nspanel_event.page == nextion.pages.home }}' - '{{ nspanel_event.page == nextion.pages.home }}'
- '{{ trigger.to_state.state not in ["unavailable", "unknown", "", None] }}'
sequence: sequence:
- variables:
# Hardware Button PIC
current_hardware_button_state: '{{ nextion.pics.hardware.button[trigger.to_state.state] }}'
##### SET hardware Button PIC on Home Page #### ##### SET hardware Button PIC on Home Page ####
- service: '{{ nextion.commands.printf }}' - service: '{{ nextion.commands.printf }}'
data: data:
cmd: 'home.{{ "left" if trigger.id == "left_button_state" else "right"}}_bt_pic.pic={{ current_hardware_button_state }}' cmd: 'home.{{ "left" if trigger.id == "left_button_state" else "right"}}_bt_pic.pic={{ nextion.pics.hardware.button.off if trigger.to_state.state in ["off", "closed", "closing"] else nextion.pics.hardware.button.on }}'
continue_on_error: true
- condition: '{{ trigger.to_state.state not in ["off", "closed", "closing", "on", "open", "closed"] }}'
- delay:
milliseconds: 800
- service: '{{ nextion.commands.printf }}'
data:
cmd: 'home.{{ "left" if trigger.id == "left_button_state" else "right"}}_bt_pic.pic={{ nextion.pics.hardware.button.off }}'
continue_on_error: true continue_on_error: true
##### DATE AND TIME ##### ##### DATE AND TIME #####