SONOS TTS Script

SOLVED

After a little bit of digging I realised that I had changed the port that I was using for xxxxx.duckdns.org. Made the necessary changes in base_url and bingo TTS is working :grinning:

Thanks for the tips!

:+1: Great.

Hi there! Your script for dynamic sonos TTS play works like a charm, please give me little hint how to change language in it?

I tried add it here in script:

data_template:
entity_id: “{{ ‘media_player.’ ~ where }}”
message: “{{ what }}”
language: ‘pl’

or here in automation:

  • service: script.say
    entity_id: script.say
    data:
    variables:
    where: ‘dining_room’
    what: “Temperatura w domu wynosi {{states(‘sensor.temperature_1’)}} stopni Celcjusza, kociol obecnie ma {{states(‘sensor.temperatura_wody_w_kotle’)}} stopni Celcjusza, na dworze jest {{states(‘sensor.pogoda_temperature’)}} stopni.”
    language: ‘pl’

But it still saying in English instead of Polish :slight_smile:

Ok, that was actually problem with one missing reload I think. But now I can hear that it reads all as text without actual data from sensors. This message sent to sonos “as is” is said correctly with values from sensors.

Ok found solution, couple of posts above, Thanks :wink:

You can solve this with the following delay code. This code uses variable “sonos” as sonos speaker name or defaults to “kok” (kok means kitchen in swedish and its one name of my speakers.)

- delay: "{{ “00:%02d:%02d”|format((states.media_player[(sonos|default(‘kok’))].attributes.media_duration | int)//60, (states.media_player[(sonos|default(‘kok’))].attributes.media_duration | int)%60) }}"

This doesnt cover longer texts than 59:59 minutes but you can build it one step further.

Am I blind? I cannot find the solution, where is it please?? as I am having the same issue, it reads the text not the sensory values.

ahh thank you… I am blind!!

Been using this script for a couple of months (thank you!), everything has been working well. Upgraded to newest HA some days ago, after which the Sonos no longer resumes playing after TTS. Just to be clear: nothing changed with regards to any of the scripts that have something to do with TTS and playback.

Was there something in any of the recent updates that could’ve broken resume from snapshot? :-S

1 Like

Same with me, no changes other than using and now the Sonos script doesn’t work for resume and is playing the tts on all grouped speakers whereas before (I’m pretty sure?) it only played on the specified one?

1 Like

@krissen @greybags

Take a look at this thread:

3 Likes

@krissen @greybags There is a current bug with ungrouping players in scripts. Fixed in next release.

Adding a small delay after the unjoin should make it work even without the fix (not tested).

3 Likes

Thanks for the tip @amelchio it works (mostly) for me now. Definitely not as smooth as it was before though! Hopefully the next release fixes it up properly.

This should now be properly fixed with the just released version 0.65.6.

1 Like

Indeed it is, I updated and it was back to working perfectly again. Thanks for the great work!

1 Like

Upgrading to 0.65.6 did not resolve the issue for me.

(Have not tried, yet, if adding a delay makes a difference.)

In that case please file a GitHub issue with your exact script and a description of the problem that you see. I cannot keep track of bug reports in monster threads such as this one.

Done! Issue #13397.

Seems it depends on what kind of media was playing, prior to the TTS script being called. Details in the Github issue. (Also, removing unjoin didn’t help, nor did adding a delay.)

ignore please