Using condition entity name in notification

I want to have an automation that when the alarm panel is set to Armed Away it will check if any of the windows are open and notify me. I would like it to be able to tell me which window(s) are open. I’ve seen instances where the trigger entity name is sent via notification but not for any conditional entities. Here is my current Yaml.

alias: Windows are open on alarm set
description: ""
trigger:
  - platform: device
    device_id: 25ac79f9e982b9fef9c488c660c6fd76
    domain: alarm_control_panel
    entity_id: dada9f898b7f523b58fda4e739b436f7
    type: armed_away
condition:
  - condition: or
    conditions:
      - type: is_open
        condition: device
        device_id: bfcebe5ff1dfff2fb0d9e5cb968d4b35
        entity_id: e3573d505b71aee7e957fcd478b034be
        domain: binary_sensor
      - type: is_open
        condition: device
        device_id: 8ada5296cc70f0c05cd9c49bdb675947
        entity_id: 2ca883788b7621118d9806a16aa21bca
        domain: binary_sensor
      - type: is_open
        condition: device
        device_id: 1f72466cbe2d4804b185c15248a96cca
        entity_id: 6a3cdc2e5f2ac3ed0df5871ab1a3bcd4
        domain: binary_sensor
action:
  - device_id: 6c3bd2c917ae6155c84c98f88abeda2b
    domain: mobile_app
    type: notify
    message: Don't forget to close the
    title: Window is open.
mode: single
alias: Windows are open on alarm set
description: ""
trigger:
  - platform: device
    device_id: 25ac79f9e982b9fef9c488c660c6fd76
    domain: alarm_control_panel
    entity_id: dada9f898b7f523b58fda4e739b436f7
    type: armed_away
    variables:
      open_windows: >
        {{ ['binary_sensor.window1', 'binary_sensor.window2', 'binary_sensor.window3']
          | expand | selectattr('state', 'eq', 'on')
          | map(attribute='name') | list }}
condition:
  - condition: template
    value_template: "{{ open_windows | count > 0 }}"
action:
  - action: notify.your_phone
    data:
      message: "Don't forget to close: {{ open_windows | join(', ') }}"
      title: Window is open.
mode: single

Replace this with the entity_ids of your actual window sensors:

'binary_sensor.window1', 'binary_sensor.window2', 'binary_sensor.window3'

Replace notify.your_phone with the appropriate action for your phone.


NOTE

In case the automation’s Device Trigger doesn’t allow you to create a trigger variable, replace the Device Trigger with a State Trigger.

trigger:
  - platform: state
    entity_id: alarm_control_panel.your_panel
    to: armed_away
    variables:
      open_windows: >
        {{ ['binary_sensor.window1', 'binary_sensor.window2', 'binary_sensor.window3']
          | expand | selectattr('state', 'eq', 'on')
          | map(attribute='name') | list }}
1 Like

Thank you so much for such a quick and complete response. I’ll test it out and let you know how it goes.