music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.35k stars 52 forks source link

Snapcast not selecting proper source #3080

Closed rwjack closed 1 hour ago

rwjack commented 2 hours ago

What version of Music Assistant has the issue?

2.3.0

What version of the Home Assistant Integration have you got installed?

2024.10.1

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

MA is setting a blank source in Snapcast

How to reproduce

Add Youtube provider, add external snapcast server (is actually running on the same HAOS instance, and works, clients are functioning when not using MA)

When I play Youtube Music media through MA, it changes the Snapcast source to a blank string:

image

Here are all the available sources:

image

Spotify and TTS are the ones that work for my current setup. Default is new I presume, but nothing plays even if I select default.

I also tried playing the Youtube Music provider to an Apple TV player and it worked, so we can deduct that the Music provider is working properly.

Music Providers

YouTube Music

Player Providers

Snapcast, both individual and grouped don't work

Full log output

log.txt

Additional information

No response

What version of Home Assistant Core are your running

2024.10.3

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

OzGav commented 2 hours ago

Have you selected use existing server in the snapcast settings?

rwjack commented 2 hours ago

Yes, I have. I can see the server's clients within MA. Do I need to configure a custom stream in my Snapcast server that will listen for inbound connections from MA?

OzGav commented 2 hours ago

@SantiagoSotoC

rwjack commented 2 hours ago

Current snapserver conf:

[server]
threads = -1
datadir = /data/snapserver
[stream]
stream = spotify:///librespot?name=Spotify&devicename=HA_Snapcast&bitrate=320&volume=100&cache=/data/librespot&autoplay=true&params=--disable-discovery%20--cache-size-limit%3D2G
stream = tcp://0.0.0.0:4953?name=TTS&codec=pcm&mode=server
buffer = 3000
codec = flac
send_to_muted = true
sampleformat = 48000:16:2
[http]
enabled = true
bind_to_address = 0.0.0.0
doc_root = /usr/share/snapserver/snapweb/
[tcp]
enabled = true
[logging]
debug = false
OzGav commented 2 hours ago

It could be those stream lines…..

rwjack commented 2 hours ago

If I could migrate from my own Snapcast to the one integrated in MA, I would gladly. TTS should be covered by MA, as well as Spotify, but I'm not sure if it's possible to have Snapweb from within MA's integration of Snapcast.

^ Okay, it seems to be there. I turned off my Snapcast and switched to the MA integrated one. It can see all the clients:

image

Second thing would be the Spotify cache, is it handled by MA or should MA Snapcast/Librespot be handling it?

OzGav commented 2 hours ago

I use snap web all the time.

I don’t know what you mean by the Spotify cache. MA has it’s own Spotify provider.

rwjack commented 2 hours ago

Right, but does that Spotify provider cache media? From what I understood it's Librespot under the hood?

I have a whole other problem adding the Spotify provider itself, will open a new issue.

BTW using the integrated Snapserver works, quite odd.

OzGav commented 2 hours ago

No following the recent Spotify change to login method Marcel wrote his own Spotify provider from scratch as we couldn’t wait for librespot to be updated. As far as I know MA does not cache media, it streams it directly.

OzGav commented 2 hours ago

Just open a discussion if you want help. 1000s of people use Spotify so be sure you have found an actual bug before opening an issue.

if this issue is resolved please close.

rwjack commented 2 hours ago

I think it's best we wait for Santiago's input on this one, even if it's just for clarifying the necessary changes required to the config file of a custom Snapserver, because using a custom Snapserver still doesn't work in my case.

SantiagoSotoC commented 1 hour ago

What version of snapweb are you using? The new versions have a bug, with the stream change, that's why in the last MA version we went back to v5.0. The blank display in the list is also a snapweb bug, but it changes the stream well in the background, it just doesn't display correctly.

SantiagoSotoC commented 1 hour ago

Try something like snapdroid on android or snapclient on linux. If it works well there it is not a problem for ma. It's a client problem, snapweb needs some love but I don't have the js skills to fix it.

SantiagoSotoC commented 1 hour ago

Yes, I have. I can see the server's clients within MA. Do I need to configure a custom stream in my Snapcast server that will listen for inbound connections from MA?

Not needed, we use the snapcast api to create and delete streams.

rwjack commented 1 hour ago

What version of snapweb are you using?

Snapweb 0.8.0: https://github.com/rwjack/addon-snapserver-spotify/blob/83e5abf69f0f76a1df0e41e3ce29e822d557c549/snapserver/Dockerfile#L21

And 0.29.0 for the Snapserver.

I'll try manually downgrading Snapweb. What version do you recommend?

Not needed, we use the snapcast api to create and delete streams.

Hmm, so what else could be the issue then? 2 of the snap-* clients are in the same subnet as HA, so it's definitely not a firewall issue.

Perhaps I'd need to expose these on my Snapserver container?

Also make sure that the ports between 4953 and 5153 inclusive are open

rwjack commented 1 hour ago

I definitely need to stick to my current Snapserver because of how librespot works. With MA, HA has no way of knowing if Spotify is actually playing (default Spotify integration), and I have no way of starting playback via HA (Spotcast integration)

rwjack commented 1 hour ago

Okay, Snapweb 0.7.0 seems to show the proper source now, and after setting my Snapserver container to host_network: true - it plays media from MA properly. Thanks for the info guys!

SantiagoSotoC commented 1 hour ago

Okay, Snapweb 0.7.0 seems to show the proper source now, and after setting my Snapserver container to host_network: true - it plays media from MA properly. Thanks for the info guys!

I still recommend you, version 5.0 is uglier, but it is the last one that does not use react.