I have an automation that is doing all the actions from my interactions with an NS-panel.
This is the trigger:
trigger:
- platform: numeric_state
entity_id: sensor.ns_panel_last_click_va
above: '150'
below: '500'
id: color_temp
and the action is:
- choose:
- conditions:
- condition: trigger
id: color_temp
sequence:
- service: light.turn_on
data:
color_temp: '{{ states("sensor.ns_panel_last_click_va") | int }}'
target:
entity_id: '{{ states("input_text.ns_panel_kitchen_selected_device") }}'
default: []
input_text.ns_panel_kitchen_selected_device
has the state light.kokslampa
and is set previously.
(The state is cleared when I release the screen. If I change it to keep the state then I can trigger the above in services and it works fine)
This is what the trace looks like after I try to change the color temp, notice the time.
Yet I have an state update:
That should have triggered the automation (?).
This is the complete automation (it’s rather big).
It’s the last trigger, and the last choose that should have been triggered.
alias: ns panel kitchen actions
description: ''
trigger:
- platform: template
value_template: '{{ states(''sensor.ns_panel_last_click_va'') is match("\d+,\d+,\d+") }}'
id: color change
- platform: template
value_template: >-
{{ states('sensor.ns_panel_last_click_va') is
match("light.*|switch.*|climate.*") }}
- platform: state
entity_id: sensor.ns_panel_current_display_page
to: '13.00'
id: thermostat
- platform: state
entity_id: sensor.ns_panel_brightness_slider
id: brightness change
- platform: template
value_template: >-
{{ states('sensor.ns_panel_last_click_va') != "" and
states('sensor.ns_panel_last_click_va') != "newtxt"}}
for: '00:00:02'
id: long
- platform: numeric_state
entity_id: sensor.ns_panel_last_click_va
above: '150'
below: '500'
id: color_temp
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_current_display_page
state: '2.00'
sequence:
- service: homeassistant.toggle
data: {}
target:
entity_id: '{{ states(''sensor.ns_panel_last_click_va'') }}'
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_current_display_page
state: '8.00'
sequence:
- service: homeassistant.toggle
data: {}
target:
entity_id: '{{ states(''sensor.ns_panel_last_click_va'') }}'
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_current_display_page
state: '13.00'
sequence:
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: climate.vardagsrum
sequence:
- service: input_text.set_value
data:
value: climate.vardagsrum
target:
entity_id:
- input_text.ns_kitchen_temp
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=43
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=51
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=49
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=47
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: climate.matilda
sequence:
- service: input_text.set_value
data:
value: climate.matilda
target:
entity_id:
- input_text.ns_kitchen_temp
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=42
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=50
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=49
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=47
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: climate.david
sequence:
- service: input_text.set_value
data:
value: climate.david
target:
entity_id:
- input_text.ns_kitchen_temp
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=42
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=51
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=48
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=47
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: climate.sovrum
sequence:
- service: input_text.set_value
data:
value: climate.sovrum
target:
entity_id:
- input_text.ns_kitchen_temp
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=42
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=51
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=49
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=46
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: script.ns_kitchen_temp_up
sequence:
- service: script.ns_kitchen_temp_up
data: {}
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: script.ns_kitchen_temp_down
sequence:
- service: script.ns_kitchen_temp_down
data: {}
default: []
- choose:
- conditions:
- condition: state
entity_id: sensor.ns_panel_last_click_va
state: script.ns_kitchen_temp_boost
sequence:
- service: script.ns_kitchen_temp_boost
data: {}
default: []
default: []
- choose:
- conditions:
- condition: trigger
id: thermostat
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_text.ns_kitchen_temp
state: climate.vardagsrum
sequence:
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=43
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=51
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=49
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=47
default: []
- choose:
- conditions:
- condition: state
entity_id: input_text.ns_kitchen_temp
state: climate.matilda
sequence:
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=42
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=50
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=49
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=47
default: []
- choose:
- conditions:
- condition: state
entity_id: input_text.ns_kitchen_temp
state: climate.david
sequence:
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=42
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=51
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=48
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=47
default: []
- choose:
- conditions:
- condition: state
entity_id: input_text.ns_kitchen_temp
state: climate.sovrum
sequence:
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.kitchen.pic=42
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.matilda.pic=51
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.david.pic=49
- service: esphome.ns_kitchen_send_command
data:
cmd: Thermostat.sovrum.pic=46
default: []
default: []
- choose:
- conditions:
- condition: trigger
id: long
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ states('sensor.ns_panel_last_click_va') in
['light.davids_lampa', 'light.matildas_lampa',
'light.skapen', 'light.kokslampa'] }}
sequence:
- service: esphome.ns_kitchen_send_command
data:
cmd: >-
Colorwheel.vprevpage.val="{{
states('sensor.ns_panel_current_display_page') |
replace(".00","") }}"
- service: input_text.set_value
data:
value: '{{ states(''sensor.ns_panel_last_click_va'') }}'
target:
entity_id: input_text.ns_panel_kitchen_selected_device
- service: esphome.ns_kitchen_set_page
data:
page: 14
- choose:
- conditions:
- condition: template
value_template: >-
{{ states("sensor.ns_panel_last_click_va") in
['light.davids_lampa', 'light.matildas_lampa',
'light.skapen'] }}
sequence:
- service: esphome.ns_kitchen_send_command
data:
cmd: vis h1,0
- service: esphome.ns_kitchen_send_command
data:
cmd: vis p0,0
default:
- service: esphome.ns_kitchen_send_command
data:
cmd: vis colorWheel,0
- service: esphome.ns_kitchen_send_command
data:
cmd: vis h1,1
- service: esphome.ns_kitchen_send_command
data:
cmd: vis p0,1
- service: esphome.ns_kitchen_send_command
data:
cmd: >-
h1.val={{state_attr(states('sensor.ns_panel_last_click_va'),
'color_temp')}}
- service: esphome.ns_kitchen_send_command
data:
cmd: >-
h0.val={{state_attr(states('sensor.ns_panel_last_click_va'),
'brightness')}}
default: []
default: []
- choose:
- conditions:
- condition: trigger
id: color change
sequence:
- service: light.turn_on
data:
rgb_color: '{{ states("sensor.ns_panel_last_click_va").split(",") }}'
target:
entity_id: '{{ states("input_text.ns_panel_kitchen_selected_device") }}'
default: []
- choose:
- conditions:
- condition: trigger
id: brightness change
sequence:
- service: light.turn_on
data:
brightness: '{{ states("sensor.ns_panel_brightness_slider") }}'
target:
entity_id: '{{ states("input_text.ns_panel_kitchen_selected_device") }}'
default: []
- choose:
- conditions:
- condition: trigger
id: color_temp
sequence:
- service: light.turn_on
data:
color_temp: '{{ states("sensor.ns_panel_last_click_va") | int }}'
target:
entity_id: '{{ states("input_text.ns_panel_kitchen_selected_device") }}'
default: []
mode: single