#last_reported trigger

1 messages · Page 1 of 1 (latest)

plucky fractal
#

if i want to trigger when last_* state is longer than 5m, is this the proper way to achieve that?

trigger: numeric_state
entity_id:
  - sensor.bthome_sensor_f289_temperature
attribute: last_changed
above: 300
id: last_changed
enabled: true

i want to be able to turn something off in a condition if that trigger id occurs.

cyan hemlock
#

last_changed isn't an attribute, it's a property of the state object. But you don't need to use it, you can just set up a trigger that will fire whenever the state hasn't changed for 5 minutes:

  - trigger: state
    entity_id: sensor.bthome_sensor_f289_temperature
    state: null
    for:
      minutes: 5
plucky fractal
#

i think that will do it. thought i might use {{ (as_timestamp(now()) - as_timestamp(states.sensor.bthome_sensor_f289_temperature.last_reported)) }} as a value template or something.

cyan hemlock
#

Well it depends what you are trying to achieve also. I just noticed your second template (and mine, since I copied yours) used last_reported instead of last_changed.

You’d use last_reported if you’re trying to determine if a sensor went offline and whatever integration you’re using isn’t appropriately detecting that it is unavailable.

You’d use last_changed if you want to know that the state of the sensor hasn’t changed, but it may still be functioning correctly.

If you wanted to use last_reported then your only option is the template trigger.

plucky fractal
#

the only reason i noticed it was that the sensor shows how long its been since "last_changed" and "last_reported" in its modal ui: