Sonos and TTS (Google) fails

I think this may be isolated to you guys, I have a similar setup (Google TTS to Sonos for alerts) and mine is working fine on all latest revisions of Supervisor and HA. According to the error message you shared, you need to make sure you can connect via port 1400.

I have TCP 80, 443, 445, 2869, 3400-3401, 3445, 3500, 4444, and 1400-1500 open to my speakers. I have found Sonos to be very finicky around accessing ports, if you have one blocked that it wants it’ll complain.

See here for more detail (and UDP port list): Sonos Support

I do not think the ports has to be open on the WAN side. I have never had them open - I have just one LAN, where everthing local can reach eachother freely. Sonos has been working fine for many years.

No, not yet :slight_smile:

A bit of progress.
When I type something to say Home Assistant write a file as it is suppose to. Sonos however fails to play it. It says, that it can not play the file as the connection to Home Assisant vanished/failed.

Mayby it is a port issus at SpikeyGG suggested. I will try is.

Sonos can only play from HTTPS sources. Make sure HA is setup correctly with SSL. Have the Sonos app open on a phone and HA open in a browser or app on another device. Send the TTS from HA and see what the Sonos app says the source link is.

Yeah, I wasn’t talking about WAN side. If you don’t block anything locally, you should be fine.

I tried this and then get this message on the Sonos app.
can not play a94a8xxxx_sv_google_translate.mp3-lost connection to xxxx.duckdns.org:8123.

I have not made any changes to the settings for SSL or anything else other than the updated HA.

Sonos App says the same at my place.

Web-interface to Sonos:

http://192.168.1.124:1400/tools.htm

I did a NSlookup and got this output:

<mydomain>.duckdns.org: dns (138 ms) -> <external IP> mdns (0 ms) -> failed netbios (0 ms) -> failed

I am also sure, that Lets Encrypt (SSL) is working fine and all the right ports are open.

Pinging from the web-interface (Sonos):

running /bin/ping -c 3 <mydomain>.duckdns.org
PING <mydomain>.duckdns.org (<external ip>): 56 data bytes
64 bytes from <external ip>: seq=0 ttl=64 time=1.341 ms
64 bytes from <external ip>: seq=1 ttl=64 time=1.258 ms
64 bytes from <external ip>: seq=2 ttl=64 time=1.173 ms

--- <mydomain>.duckdns.org ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 1.173/1.257/1.341 ms

And the traceroute:

running /usr/bin/traceroute <mydomain>.duckdns.org
traceroute to <mydomain>.duckdns.org (<external ip>), 30 hops max, 38 byte packets
 1  <external ip> (<external ip>)  0.916 ms  3.424 ms  0.912 ms

Don’t know what to say then… mine is working fine. I just remember when I was setting up Sonos and TTS a year ago that it did not like an http address and that “lost connection” message was exactly what I was getting. I could not push anything to Sonos until I setup a DNS loop back/redirect in my DNS server to redirect any internal connections from my external HTTPS to the internal IP. Also, I don’t use duckdns, rather I use a lets encrypt certificate on my Synology and share that with the HA container. So maybe there were some changes to duckdns recently? Or maybe something changed from the ISP? Going back to the ports comment, maybe check that HA is externally accessible and specifically the www folder or whichever folder holds the TTS audio files. Take the URL that Sonos is supposed to be playing and put it into a web browser. The file should play there or may give you a security warning or may not be found. The way Sonos handles media is HA does not send the audio file, rather HA tells Sonos “I want you to play this” and sends a link to where the file is. Sonos validates the URL, goes there and then retrieved the file. If that file is not accessible due to network issues, security issues, or misconfigured file sharing, it will error out.

I tried to ping homeassistant.local and found that it only returned the IPv6 adress.

I setup a DNS server and added homeassistant.local to point at the local IP of the Home Assistant.

I can now ping and do a NSlookup on Sonos (web-interface). Now I get the local IPv4 adress

homeassistant.local: dns (9 ms) -> 192.168.1.XX mdns (1001 ms) -> failed netbios (0 ms) -> failed

How ever it did not fix the error. Still the same error message.

I tried to change the base_url under tts: in the configuration.yaml to the local HomeAssistant IP. That also did not help.

Just to add I’m getting the same issue. Snapshot and restore seem to function fine, as well as throwing music up on it. However no TTS plays. This has been working fine previously for well over a year.

I have the same problem since version 2021.8.7. It did work fine before.
Now the tts wont play. Sonos cannot connect.
No audio file generated in tts folder. I have removed the old files.

Update: Tested with mp3 file in www folder, same issue.
Problem is also described in: Sonos media_player.play_media can't access local files · Issue #55223 · home-assistant/core · GitHub

Update2: When I host the mp3 file on another home assistant also with https, but without duckdns the mp3 plays fine.

Same problem here. It worked until Sunday 22nd of August, which means it worked with 2021.8.8.

EDIT: I am using duckdns.org, as both internal and external URL, and the FQDN is resolved to the internal IP for HA in my DNS, if that has anything to say. But again, this has been the case for a long time now, and it just recently stopped working.

It is a bit strange that the problem did not start at the same time for us.

I am going to report it as an issue at core since I can not figure out where the issue is caused.

1 Like

Same issue for me.

I am having the same issue since the last update, before it worked flawlessly. I already checked firewall, internal/external link, Sonos media player works well from Home assistant, TTS file is being created, TTS works on google mini speakers, but Sonos just won’t play them… Running out of ideas

It’s working for me now.

Follow this guide: The easiest way to secure Home Assistant with HTTPS | dummylabs.com

And the last thing that did the trick was adding the below text to configuration.yaml
(in http section)

  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24

This do not seem to be working for me. Same error.

However I have not changed my SSL since I use the DuckDNS add-on, where you only get a token. This can not be used with the Nginx Proxy Manager (as far as I can see)

This is no longer a Sonos or a TTS issue. This is a DuckDNS/Nginx/HTTP configuration issue. My suggestion is to read some of the changes and specifically breaking changes of the past few major versions of HA (ie 2021.6, 2021.7, 2021.8) and if you run HA Supervised or HAOS, the supervisor and HAOS changes as well.

Hello,
Can you tell me exactly where to look on the information? I am completely Lost :frowning:

1 Like