Hi all,
I have a script which I am trying to get to play a message if my alarm is triggered at night. I can get the tts to play as a test on one speak only but cannot find a way to group speakers so they all activate at once. Here is the script I am using (copied). If I add additional locations under where it refuses to work.
There must be a much better way of doing this but being a noob I’m struggling.
test_tts:
alias: Test for TTS
sequence:
- data:
variables:
what: Test.
where: Lounge
entity_id: script.say
service: script.turn_on
say:
alias: Sonos Text To Speech
sequence:
- service: sonos.snapshot
data_template:
entity_id: '{{ ''media_player.'' ~ where }}'
- service: tts.google_translate_say
data_template:
entity_id: '{{ ''media_player.'' ~ where }}'
message: '{{ what }}'
- delay:
seconds: 1
- delay: "{% set duration = states.media_player[where].attributes.media_duration\
\ %} {% if duration > 0 %}\n {% set duration = duration - 1 %}\n{% endif %}\
\ {% set seconds = duration % 60 %} {% set minutes = (duration / 60)|int % 60\
\ %} {% set hours = (duration / 3600)|int %} {{ [hours, minutes, seconds]|join(':')\
\ }}"
- service: sonos.restore
data_template:
entity_id: '{{ ''media_player.'' ~ where }}'