Numeric_state above: only fires when going from unknown to X

I have an automation where I only want it to run when the sensor value changes and the new value is above 0.

When i fresh start HA the original values are “unknown” and when a value of 10 gets sent. Automation fires. Makes sense. 10 > 1 = true.

But if I then send a 15 later… no joy… 15 > 1 = true as well. But didn’t fire.

Automation yaml below.

alias: Update Impedance
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.impedance_jason_2
    id: jason_impedance_change
    above: 1
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: jason_impedance_change
        sequence:
          - service: input_number.set_value
            data:
              value: "{{ states('sensor.impedance_jason_2') | int(0) }}"
            target:
              entity_id: input_number.helper_jason_proxy_impedance
    default: []
mode: queued
max: 10


Should I switch from doing a numeric_state to doing a template sensor that casts the value to a number? Thanks!

If the value is already above 1 then there is no transition of the trigger from “false” to “true” for the trigger to re-trigger. the trigger is already “true” both before and after the change.

if you always want the automation to trigger whenever the value of the entity changes then use a stater trigger and set the “to:” option to blank.

then on every state change only the trigger will fire and you can check that the value of the state of the entity is greater than 1 by using a numeric_state condition.

ok, i see what you mean. what i am trying to avoid is on restart of HA the sensor value goes to unknown. i don’t want that state to trigger. the automation, only when there is a numeric change. do you think your recommendation will work for that scenario too?

change the state trigger to:

trigger:
  - platform: state
    entity_id: sensor.impedance_jason_2
    id: jason_impedance_change
    to:
    not_from: 'unknown'
1 Like

haha didn’t know the not_from was an option :slight_smile: that’s perfect!!!

1 Like