Just wrapping this up in case it helps anyone!
It all came down to either the external URL or the SSL cert (or lack thereof).
I tried for hours and hours all kinds of different TTS scripts and none would ever play over the Sonos (even though I could control music on the Sonos through HA with no problems).
In the end, just enabled Home Assistant Cloud, and it worked. So I feel like it has something to do with unsigned calls from HA to Sonos…
Anyway, glad it works now.
the way that tts.speak works is that it creates the audio file then exposes it with the local url of your home assistant and points sonos to it. so unlike media controls, where the commands are sent to sonos, in this case, sonos needs to be able to http back to home assistant. if you have home assistant ssl’ed or somehow separated in different networks, then sonos would need to be able to get the correct (usually external ssl link)…
if you have them all on the same subnet and no ssl… which is the config i run, then i dunno… but regardless, glad it’s working
Instead of starting a new topic, I will try to hop on this train, as I’m having the same conditions.
I had set up some TTS alarms with my Sonos and a Nest Hub 2, and they used to work. Then, I connected my HA server (HAOS) to the outside world using DuckDNS. A while later, I discovered that I cannot use TTS anymore.
The rest of the automation does work, it’s just the TTS which doesn’t.
I use the GUI, and do:
Media player → Play media → Select the speaker, then Pick Media → TTS
I tried with both Home Assistant Cloud (even though I have not connected that, just to see what happens) and Google Translate. These are the two TTS options I have. I select the correct language (Canadian French), enter the text, save, and… nothing…
Here’s the code for that action (created from the GUI). Any help will be welcome.