I know the answer will be obvious but I have spent a couple of hours wrestling with this issue. Appreciate any help offered.
I have a multitude of automations, many of them have announcements and in each case I have built all the code for Sonos into the automation. I would like to move the bulk of the code into a script which is called by the automation and inserts the text from a variable in the automation. But I cannot get it to work.
The test script is:
sonos_test:
alias: "Sonos test"
sequence:
- service: tts.cloud_say
data_template:
entity_id: media_player.dining_room_sonos
message: "{{ text_message }}"
options:
gender: female
language: en-GB
The calling automation is:
automation:
- alias: 'test'
id: test01
trigger:
- platform: state
entity_id: input_boolean.test
action:
- service: script.sonos_test
data_template:
variables:
text_message: 'This is a test of the Sonos announcement script!'
No error messages are shown, but the trace in the script shows no text passed to the script.
Executed: March 11, 2022, 17:01:00
Result:
params:
domain: tts
service: cloud_say
service_data:
entity_id: media_player.dining_room_sonos
message: ''
target: {}
running_script: false
limit: 10
Any help mucho appreciated.