Help me understand why this doesn't trigger

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

What was the state before the 260?

I can’t know for sure since I don’t see any trace and its very hard to see in timeline.
But the NS panel is set up to send a state (it could be a number, entity or RGB code) then clear it when I lift the finger.
So because of this I’m fairly sure it was nothing as state previously.

I would suggest first to set another trigger, which triggers on any change of the entitiy and doublecheck, what was before and afterwards.

Just to make sure you understand what your trigger is actually doing: it will only trigger in two situations:

  • when the value goes from a number below 150 to a number above 150
  • when the value goes from a number above 500 to a number below 500

Having the thresholds this way around (above smaller than below) may not work at all. The note in the docs says “Listing above and below together means the numeric_state has to be between the two values”, although that might only refer to the examples on the page.

The rest of your code suggests that the sensor state can also be empty strings or “newtxt” — that is not going to play nicely with a numeric_state trigger.

That could be it!
Since the value is most likely empty before it goes to a numeric value then the it hasn’t by definition went from below to above the thresshold.
I will probably replace it with a regex match pattern then.

For now, I can make it as easy as

- platform: template
    value_template: '{{ states(''sensor.ns_panel_last_click_va'') is match("[12345]\d{2}") }}'

It will trigger on below 150 and above 500 also but, at the moment that is not an issue since I don’t have anything in the NS panel that sends that kind of data yet.
If I do then I just have to change it I guess.
Or I just make the panel send “color_temp xxx” instead and it’s a more fool prof method for the feature.

I changed the NS-panel to send color_temp[number] and replaced the trigger with:

  - platform: template
    value_template: '{{ states(''sensor.ns_panel_last_click_va'') is match("color_temp\d+") }}'
    id: color_temp

And it works beautifully.
This makes me think that I could perhaps use this variable in the same way for more actions.