I need some help configuring a template. I have a group of 7 door sensors and an automation is fired if any of these open for the first time, which works fine.
- alias: 'Manual - Trigger alarm when doors are opened'
trigger:
- platform: state
entity_id: group.Door_sensors
to: 'on'
condition:
condition: template
value_template: "{{ states('alarm_control_panel.home_alarm') != 'disarmed' }}"
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.home_alarm
- service: notify.mobile_app_XXX
data_template:
title: 'Alarm'
message: >
{% for entity in trigger.to_state.attributes.entity_id %}
{% if states(entity) == 'on' %}
{{ state_attr(entity, 'friendly_name')}} opened
{% endif %}
{% endfor %}
In a notification to my mobile if have the entity that opened listed, but it looks like in the message it writes a line for each other sensor in the group as well resulting in a big ugly notification on my phone.
Can someone help me to just get the one line with the entity that acually opened first?