Is it possible to include the name of the triggering device in a TTS message? Essentially trying to create a single automation rule that announces which water leak sensor is triggering without having to write individual automation for each sensor.
Yes, it is possible to include the name of the triggering device in a TTS (Text-To-Speech) message in HA.
To do this, you can use the {{ trigger.entity_id }} template in your automation rule. This template will be replaced with the entity ID of the device that triggered the automation.
For example, if you have three water leak sensors with entity IDs binary_sensor.water_leak_sensor_1, binary_sensor.water_leak_sensor_2, and binary_sensor.water_leak_sensor_3, you can create an automation rule that will announce the name of the triggering sensor as follows:
alias: Water Leak Alert
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.water_leak_sensor_1
- binary_sensor.water_leak_sensor_2
- binary_sensor.water_leak_sensor_3
to: "on"
action:
- service: tts.google_say
data:
message: "Warning: Water leak detected by sensor {{ trigger.entity_id }}"
entity_id: media_player.google_home
mode: single
In this example, the TTS message will be “Warning: Water leak detected by sensor [entity ID of triggering sensor]”.