Variables in notify message

Hi,

I use some automations with presence detection as a trigger. It turns off switches, TV etc. It also triggers a notification which sends a message stating if my windows are still open based on contact sensors.

            {% if states('group.windows') == 'on' %}
                 At least one window is still open
            {% elif  states('group.windows') == 'off'%}
                 All windows are closed
            {% else %} 
                 Error detecting window state
            {% endif %}

groups.yaml:

windows:
  name: Windows
  entities:
    - binary_sensor.openclose_7
    - binary_sensor.openclose_9
    - binary_sensor.openclose_10
    - binary_sensor.openclose_11
    - binary_sensor.openclose_12
    - binary_sensor.openclose_21
    - binary_sensor.openclose_22

This works well. However, in case windows are still open, I like to name these sensor in the message as well. Something like “The following windows are still open: Kitchen, Bathroom…”

Any idea what’s a good approach to achieve this?

Best
Pete

See an example here made by 123/Taras-

1 Like

thanks for pointing me to this solution!