TTS announcement on Sonos

Good day everyone.

I’m brand new to home assistant, but fairly technically minded. Having fun so far!
I’m trying to get a TTS service running on my Sonos.

  • I have two sonos connected. Both Sonos One. Both running S2 firmware.
  • They were automatically detected by HA:
    entity_id: media_player.kitchen
    entity_id: media_player.dining_room
  • I can play/pause/change tracks from the HA dashboard

First I tried this one, which I found in the forums:

service: media_player.play_media
data:
  media_content_id: media-source://tts/google_translate?message="I am very loud"
  media_content_type: music
  announce: true
  extra:
    volume: 80
target:
  entity_id: media_player.kitchen

When I run the “Then do”, I get this error: Provider google_translate not found

Second, I tried to build the automation from scratch in the UI, which resulted in:

service: media_player.play_media
target:
  entity_id: media_player.kitchen
data:
  media_content_id: >-
    media-source://tts/tts.google_en_com?message=Hello+Homey%2C+you+can+play+any+text+on+any+supported+media+player%21&language=en-ca
  media_content_type: provider
metadata:
  title: Hello Homey, you can play any text on any supported media player!
  thumbnail: https://brands.home-assistant.io/_/tts/logo.png
  media_class: app
  children_media_class: null
  navigateIds:
    - {}
    - media_content_type: app
      media_content_id: media-source://tts
    - media_content_type: provider
      media_content_id: >-
        media-source://tts/tts.google_en_com?message=Hello+Homey%2C+you+can+play+any+text+on+any+supported+media+player%21&language=en-ca

This one says “Action successfully run”, but nothing comes out of the Sonos.

Could someone please help me in getting a TTS working over Sonos?

Thanks in advance!

why not this?

service: tts.speak
target:
  entity_id: tts.google_en_com
data:
  media_player_entity_id: media_player.sonos
  message: hello world

you have to make sure you have the google tts integration added of course:

Thanks for the quick reply.
I tried as you suggested, but no luck (nothing comes out of the speaker).


And yes, the google tts integration is already added.

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.

glad you got it to work.

do you have your home assistant on ssl?

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