Using variables in HTML email notification

I’ve been playing recently with rich HTML email notifications. These are specifically to provide status information vs. status alerts. I want them to provide relevant information in the alert, but haven’t figured out how to replace some of the HTML with sensor names, sensor states, etc.

  action:
  - service: notify.google_smtp
    data:
      title: Home Assistant Alert
      message: Tesla range low
      data:
        html: >
          <!DOCTYPE html>
          <html>
          <head>
         </head>
         <body>
         <h4>Status Information:</h4>
         <h2>Tesla battery range now [sensor.tesla_battery_range]</h2>
         </body>
         </html>

Trying to get ‘sensor.tesla_battery_range’ to be the state of that sensor…
I tried {{ states(‘sensor.tesla_range_sensor’) }}
But it errors out in Configuration test.

Thoughts?

How about?

{{ states.sensor.tesla_range_sensor.state }}
1 Like

Yep, that did the trick, thank you!