I am trying to use the Device name that triggered the automation instead of having to type out the phrase:
“The Washing Machine Water Leak Sensor detected a leak in the house!” or
“The Guest Bathroom Water Leak Sensor detected a leak in the house!”
What I want to be able to type out is:
“The <device_name> detected a leak in the house.”
That way I do not have to type out an action for each water leak sensor. Instead, I can create a trigger for each water leak sensor and just type one action using the name of the Trigger that activated the automation.
Below is a piece of my YAML code that only has the single trigger. My final code will have 8 triggers. What I want is to use the name of the Trigger that activated the automation. How would I modify the message in the action section to capture the device name of the trigger?
description: ""
mode: single
triggers:
- trigger: state
entity_id:
- binary_sensor.washing_machine_water_leak_sensor_2
to: "on"
conditions: []
actions:
- action: notify.alexa_media_bedroom_echo
metadata: {}
data:
message: >-
<audio
src="soundbank://soundlibrary/scifi/amzn_sfx_scifi_alarm_04"/>ALERT:
The Washing Machine Water Leak Sensor detected a leak in the house!
data:
type: tts
Just for reference, I know I can type:
{{device_name('binary_sensor.washing_machine_water_leak_sensor_2')}}
to get the device name. But what I want is instead of using ‘binary_sensor.washing_machine_water_leak_sensor_2’, I want to use the trigger variable to get the same results.