Hello,
i made a rest service to generate a TTS and play an audio on a remote server (a pizero with speaker)
I want to use it as a “notifier” for my home automation.
I configured my service like that and it is working good:
rest_command:
playtts:
url: http://192.168.1.5:8080/play
method: POST
payload: '{"data":{"text": "{{ text }}"}}'
content_type: 'application/json; charset=utf-8'
and now i trigger the automation like that:
platform: device
type: turned_on
device_id: xxxxxxxxxxxxxxxxxxxx
entity_id: switch.luce_cucina
domain: switch
this is the action:
service: rest_command.playtts
data:
text: Luce cucina turned on.
But i have multiple switches, shutters, curtains in my Home. Is there a way to configure a single automation and get its state inside the action?
I explain better with this example:
Configured devices for multiple activation:
platform: state
entity_id: &motion
- switch.luce_cucina
- switch.luce_sala
- shutter.bedroom
- ETC
to: 'on'
(ref. https://community.home-assistant.io/t/using-a-single-automation-for-multiple-devices/227084/8)
Here in the action instead of manually writing the text:
service: rest_command.playtts
data:
text: **trigger.device.get_activation**
where trigger.device.get_activation is something like… “Bathroom light turned on”
or “Bedroom shutter is now open”
Is that possible? Or I have to manually specify a single automation for every device i have in my House and manually write the text param in it?
I mean, something dynamic is more efficient, so every time I set up a new device at home I don’t have to worry about creating an activation for my notifier
Thanks