Sensor values in alerts

Very new to HA here, so please go easy :slight_smile:

I have setup a number of automations, but I want to be able to use what I would consider to be variables - however I may have got the wrong terminology - Automation below is a check for CO2>1000ppm… Rather than just say high CO2 and the sensor name, I’d like to add the value, which I assume is some kind of variable.

How to find all these variable names? I got the sensor state just by searching and extracting from someone else code, however others talk about these as though they memorised them all - is there some reference reading material I can check out?

So in general how can I find these variables to use, and
any ideas what the correct variable would be to use that contains the sensor data of the correct CO2 sensor?

Thank you!

alias: CO2 Level High
description: ''
trigger:
  - type: value
    platform: device
    device_id: 248cb5beff59c58885ccab418822c46a
    entity_id: sensor.netatmo_ws1_indoor_office_co2
    domain: sensor
    above: 1000
  - type: value
    platform: device
    device_id: d6f899533e38082bdc6ddb18e8473b1a
    entity_id: sensor.netatmo_ws1_indoor_bedroom_co2
    domain: sensor
    above: 1000
  - type: value
    platform: device
    device_id: 4ae22468c3f20d88638fb52be210f364
    entity_id: sensor.netatmo_ws1_indoor_izzi_bedroom_co2
    domain: sensor
    above: 1000
  - type: value
    platform: device
    device_id: cbd5502d6335b440f06735027e93260b
    entity_id: sensor.netatmo_ws1_indoor_co2
    domain: sensor
    above: 1000
condition: []
action:
  - service: notify.all_mobile_devices
    data:
      message: 'Alert CO2 High {{ trigger.to_state.attributes.friendly_name }}'
mode: restart

Please format your code properly as explained in the community guidelines point 11.

What is used here is called templating, you can find more in the docs here and here

To get the value of the sensor that triggered the alert, change your action to this:

service: notify.all_mobile_devices
data:
  title: "Alert CO2 High!"
  message: > 
    {{ trigger.to_state.name }} detected a CO2 Value of {{ trigger.to_state.state }}

Perfect, thank you for the direction!