Notify which condition in my automation was used (Doors open)

Hi,

i’ve got an automation which sends me a notification whenever a door is still open. On the “conditions” if a have a list of contact sensors i check with the “OR” condition.

Now i want to send a notification with the name of the door that is still open. But i cannot get my head around it on what to check for. And i cannot see it from the trace of the automation as well.

The Automation looks as follows:

id: 'xxx'
alias: 'Security: There are doors still open'
description: ''
trigger:
  - platform: state
    entity_id:
      - alarm_control_panel.alarm
    to: arming
    from: disarmed
condition:
  - condition: or
    conditions:
      - type: is_open
        condition: device
        device_id: xxx
        entity_id: binary_sensor.front_door
        domain: binary_sensor
      - type: is_open
        condition: device
        device_id: xxx
        entity_id: binary_sensor.back_door
        domain: binary_sensor
action:
  - service: notify.mobile_app_xxx
    data:
      title: Security
      message: Doors are still open {{ name of the door/s }}
mode: single

Thanks for your advice.

id: 'xxx'
alias: 'Security: There are doors still open'
description: ''
trigger:
  - platform: state
    entity_id:
      - alarm_control_panel.alarm
    to: arming
    from: disarmed
    variables:
      open_doors: >
        {{ expand('binary_sensor.front_door', 'binary_sensor.back_door')
          | selectattr('state', 'eq', 'on')
          | map(attribute='name') | list }}
condition:
  - condition: template 
    value_template: "{{ open_doors | count > 0 }}"
action:
  - service: notify.mobile_app_xxx
    data:
      title: Security
      message: Doors are still open {{ open_doors | join(', ') }}
mode: single
1 Like

Thanks a lot. Works like a charme.

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title signaling to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.