Automation to return sensor value that triggered it

Hi. I have high & low temp alarm automations. My aim to add a list of entities that can trigger it, then have the automation send the alarm with the info on which entity triggered it. It seems to partially work, but I can’t get it to report the current temperature with


The complete high temp one is as follows:

  title: >-
    ALERT - High temperature alarm in":" {{
    trigger.to_state.attributes.friendly_name }}
  message: >-
    Temperature is high - current temperature is {{
    states('trigger.to_state.state') }} {{ '°C' }}

What am I missing?

Try this:

  message: >
    Temperature is high - current temperature is {{ trigger.to_state.state }} °C
1 Like

Brilliant, thanks a lot. I’m having trouble understanding the syntax for templates. Am I interpreting correctly that anything wrapped in states, as ‘X’ below, has to be explicitly referring to an entity?

{{ states('X') }}

Whereas the one below is dynamic?

{{ trigger.to_state.state }}

Yes, exactly. And a trigger variable is not an entity.

The other thing that trips people up when learning templates is the difference between an entity attribute and a state object property. Petro wrote a great post on that here: