Trigger on Temperature Change

I’m trying to fire an MQTT message each time the temperature changes. This works when I run it manually, but doesn’t trigger on every temperature change:

- id: '1648947708486'
  alias: Outside Temp MQTT Send Update
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.thgn122_123_thgn132_thgr122_228_238_268_e6_01_temperature
  action:
  - service: mqtt.publish
    data:
      topic: elektra/mcsMQTT/Back_Yard/Back_Porch/Temperature
      payload_template: '{{ states(''sensor.thgn122_123_thgn132_thgr122_228_238_268_e6_01_temperature'')
        }}'
  mode: single

Doesn’t trigger at all or just not for some changes?

Have you examined the automation’s trace?

It doesn’t trigger at all. The trace says the node was not executed. It does show it as executing successfully when I run it manually, but it never executes based on a change in the temperature.

Here are the step details from the manual run:

Executed: April 3, 2022, 10:05:52 AM
Result:
params:
  domain: mqtt
  service: publish
  service_data:
    topic: elektra/mcsMQTT/Back_Yard/Back_Porch/Temperature
    payload_template: 57
  target: {}
running_script: false
limit: 10

This is working now, although I’m not sure exactly why. I tried changing the Trigger Type to numeric state with a value of From: 0. Didn’t work, so changed the Type back to just “state” and now it’s firing. Although it seems to fire on anything within the state object that changes, not just the temperature. But I’ll take it for now.

That’s how a State Trigger works.

If you want it to trigger only when its state value changes (not its attributes), add an empty to option (it’s explained in the documentation).

  trigger:
  - platform: state
    entity_id: sensor.thgn122_123_thgn132_thgr122_228_238_268_e6_01_temperature
    to: