Sonos can not play mp3

I try to play an mp3 file via a Sonos speaker with the following service.

service: media_player.play_media
target:
entity_id: media_player.hobbyraum
data:
media_content_type: music
media_content_id: http://192.168.178.80:8123/local/Martinshorn.mp3

The file is not played and in the Sonos app I see the following error

I do not understand why the Sonos app is disconnected.

I also tried media_content_id : https://xxxx.duckdns.org:8123/local/Martinshorn.mp3 with no success.

Could the problem be related to the internal / external URL set in Configuration → General
(here I have twice https://xxxx.duckdns.org:8123.

Thank you in advance.

same issue here… several others of us are having the same issue. i cant figure out why

This problem just started with me. Unable to do TTS because of it. In english the error reads “connection to xxx.duckdns.org was lost” I’ve tried IP address, I’ve tried setting / un-setting internal external adresses.

Yes, It seems the Duckdns is having a DDOS attack of some sort… so all wekeend they been having issues.

still the same :frowning: i have tried everything

anyone who has managed to solve this problem?

Same problem here…
I’ve started an issue:

Workaround: host the .mp3 public on the internet and edit your service call data.

https://community.home-assistant.io/t/sonos-and-tts-google-fails/330662/29?u=perka82

I have solved the problem by adding the lines to the http section:

http:
  use_x_forwarded_for: true
  trusted_proxies: 
    - 172.30.32.0/24

You can find the Hassio internal ip-range by looking into the Supervisor - Multicast logging.
example: mdns-repeater (6): dev hassio addr 172.30.32.1 mask 255.255.254.0 net 172.30.32.0

1 Like

Hi

I finally was able to solve the problem.
The problem is Duckdns and the solution is to use a proxy manager.

As I have a Nginx webserver running on a different host than HA I so could not install NPM on HA
as an add-on.

I did the following steps:

  • Configure config file for Nginx webserver on my host (not HA). I used a duckdns.org DNS
    (I can provide more details about the the file if needed.
  • Stop Duckdns add-on in HA
  • Addapted configuration.yaml
    http:
    use_x_forwarded_for: true
    trusted_proxies:
    - 192.168.178.129
  • Remove port forewarding 8123 from HA in my router

Now I can access my HA like https://xxx.duckdns.org (no port needed)

TTS via Sonos work again.

2 Likes

I ran into this issue when I switched to a nginx reverse proxy terminating TLS instead of having hass do it. It turns out forcing TLS v1.3 only did not sit well with Sonos, and changing the nginx config to accept TLS 1.2 also did the trick.

2 Likes

With newer hass versions this can be used:

service: media_player.play_media
target:
  entity_id: media_player.office
data:
  media_content_type: audio/mpeg
  media_content_id: media-source://media_source/local/ej_music/Pingfong - Baby Shark.mp3

https://www.home-assistant.io/integrations/media_source/

other help: https://community.home-assistant.io/t/media-player-play-media-how-to-get-the-content-id/415486/2?u=bbrendon

1 Like