Is it possible to get the (friendly) name for a sensor that triggers a condition when using groups in the entity_id? As you can see below, I’m using group.all_doors so that I don’t have to make code changes if I add sensors, but in my messaging, I’d like to be able to say that a particular sensor (Front Door, for example) is the door that actually triggered the automation.
automations.yaml
- id: automation.alarm_entry_doors_always
alias: Alarm - Entry Doors - Always
description: Triggers when alarm is armed and an entry door is opened any time.
trigger:
- entity_id: group.all_doors
from: 'off'
platform: state
to: 'on'
condition: []
action:
- service: script.turn_on
entity_id: script.alarm_triggered
data:
variables:
title: Home Alarm
automation_name: automation.alarm_entry_doors_always
automation_friendly_name: Alarm - Entry Doors - Always
alarm_delay_seconds: 30
triggered_by: [this is where I'd like to get "Front Door" or "Sliding Door" and not just the name of the group of doors that I have created]
One way would be to add each door as a trigger and then use trigger.to_state to find the entity that triggered the automation. A possible workaround I found in another topic:
However what I’m missing in your automation is a condition that checks if the alarm system is armed. Are you doing this in your script? If so I would suggest moving the condition to the automation, otherwise your script gets triggered every time a door gets opened, instead of only when the alarm system is armed.
Thanks for the response; I had a feeling I might have to go that way.
As for the rest of the code, yes, there is a check to see if the automation is still on after a period of 30 seconds. If it is, the alarm goes off; if someone has gone in and turned off the alarm (disabled the automation), then no further actions are taken.