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.33k stars 49 forks source link

Sonos speakers regularly not found/not available #2257

Closed HA-TB303 closed 1 month ago

HA-TB303 commented 4 months ago

What version of Music Assistant has the issue?

2.0.2

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

2024.5.1

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

The problem

Sonos speakers are either regularly not found or appear "not (yet) available" in MA.

This mostly happens on battery powered speakers, but I can also easily reproduce on a normal speaker and even on ethernet connected speakers.

How to reproduce

Unplug/Turn off a speaker, want 10 minutes, check: httpp://ha_ip:8123/d5369777_music_assistant_beta/ingress One or more speakers appear like: CleanShot 2024-05-12 at 10 58 26

Then check the home assistant sonos integration if speakers are actually offline: CleanShot 2024-05-12 at 10 59 20

In this case all speakers appeared unavailable in MA, when in fact only the 'logeerkamer' (A Sonos Roam) was unavailable at that time (turned off). The rest appeared ONLINE in the HA integration. Even woonkamer (a ethernet connected Sonos ARC) appeared offline in MA, but was online in the HA integration.

Disabling the speaker in MA and then enabling it again mostly "fixes" it.

This makes Sonos quit unusable within MA.

Music Providers

Youtube music RadioBrowser Music Assistant

Player Providers

(only) Sonos

Full log output

N/A (I can send on request, too much private information in there)

Additional information

No response

What version of Home Assistant Core are your running

2024.5.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)

HA-TB303 commented 4 months ago

Some extra info:

Reproduction path: All speakers are turned on and everything works well: CleanShot 2024-05-12 at 11 13 54 I then physically turn off The Sonos Roam (logeerkamer): Within 3 seconds: CleanShot 2024-05-12 at 11 15 07 I then turn on the logeerkamer (sonos roam) again: CleanShot 2024-05-12 at 11 16 18 This took only 15 seconds.....

Sometimes it takes longer and then disabling and enabling each speaker within MA resolves the issue.

HA-TB303 commented 4 months ago

Just repeated the exact same proces but now observed the Home Assistant Music Assistant addon logs:

I did so at 11:19h.

2024-05-12 11:20:14.812 WARNING (MainThread) [music_assistant.providers.sonos] No recent activity and cannot reach Logeerkamer, marking unavailable
2024-05-12 11:20:25.395 WARNING (MainThread) [soco.events_asyncio] Could not bind to 192.168.207.101:1400: [Errno 98] Address already in use
2024-05-12 11:22:25.542 WARNING (MainThread) [soco.events_asyncio] Could not bind to 192.168.207.101:1400: [Errno 98] Address already in use
marcelveldt commented 4 months ago

Looks like you have both the Sonos integration in HA active as the Sonos provider in MA, so only one of the 2 actually gets devices updates, causing issues like you describe here (as both are based on the same library). We are however going to switch MA to the new Sonos API due to more reports we're seeing (and because the old API is going to be deprecated by Sonos).

Temporary solution could be to not use the Sonos integration in HA (and only/just) use MA's players. Switching over the Sonos API is one of the important things for the next release btw.

HA-TB303 commented 4 months ago

Ah ok, I was totally unaware those should not be used at the same time. I even thought having the speakers working within HA was a requirement for MA to be able to use them.

I'll try disabling it in HA.

HA-TB303 commented 4 months ago

After removing the Sonos integration in HA ,restarting HA and reproducing it the same way, I do not notice any difference. Still the same issue. :(

I am glad to read Sonos is getting some extra love in MA soon :)

HA-TB303 commented 4 months ago

Some important thing to add:

When turning off the Sonos roam speaker and then disabling/enabling all other (unavailable) speakers in MA, WON'T fix the issue and all speakers remain unusable, even though those are physically switched on and available in the Sonos app. The only way to get all other speakers working again is to turn on the battery powered Sonos Roam.

HA-TB303 commented 4 months ago

I tried reproducing the issue the same way, but then with the ERA100 mains powered speaker.

If I unplug that speaker all speakers remain available, only the ERA 100 (Badkamer) goes offline after approximately 1 minute after unplugging it.

CleanShot 2024-05-12 at 12 13 58

So I repeated this with one other battery powered speaker (the Sonos Move 2). If I physically turn off the Move 2 (keuken), all other speakers go offline. CleanShot 2024-05-12 at 12 20 45

If I turn it on after some time all speaker go back online.

So it is safe to say this issue only appears when switching off a battery powered speaker and the issue must be within MA, since this does work correctly with the HA sonos integration.

It seems best to retest this after you guys switch to the new Sonos API and this issue may be parked until then.

Thyraz commented 4 months ago

Discovered exactly the same behavior with a Sonos Move here. Thanks for the testing and the outlook to the new Sonos API. 🙂

MuscleGeek69 commented 2 months ago

I have the same or similar problem.

Env:

Thank you!

goobags commented 2 months ago

I also unknowingly replicated this fault when my Roam went offline. Every 2 minutes the other devices would come back online for a very short period of time then back off again.

Herazio commented 2 months ago

I've had this issue for quite a while now, also in the Beta versions, but I'm glad someone was able to reproduce it and figured out what the issue was. I've never been able to get to this conclusion, but indeed. Replicated it exactly the same way as OP.

Is there currently a way to exempt certain players from being discovered on the network as a workaround, so that we can exclude the battery powered devices, based on ID or MAC or?

If I remove the Sonos Roam, obviously it will get picked up again once it actually comes back online so it gets added automagically towards MA. Just looking for a quick-fix for now so that we can enjoy MA ;).

Thanks!

HA-TB303 commented 2 months ago

Looks like the new sonos api implementation is “in progress”, so should be fixed soon.

https://github.com/orgs/music-assistant/projects/2

Sonos is pretty much unusable now if you have battery powered devices, so I can’t wait. 😎

marcelveldt commented 2 months ago

The new Sonos implementation is still WIP and should land in the new 2.2 beta very soon. In the meanwhile did you check if enabling "allow network scan" in the Sonos provider settings makes any impact ? I believe HA has that one enabled by default (and we dont)

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 21 days with no activity. Comment or this will be closed in 7 days.

HA-TB303 commented 1 month ago

Please keep this open as it’s not resolved.yet.

OzGav commented 1 month ago

You didn't answer Marcel's question

goobags commented 1 month ago

I had this issue previously. I removed the Sonos integration and relied solely on the MA/Sonos integration. I enabled the network scan as suggested by @marcelveldt and tested it over the weekend. Sonos Roam was not on the network as it had gone to sleep, and was not visible in MA however the other speakers continued to function. I would suggest checking that option and trying again.

HA-TB303 commented 1 month ago

The new Sonos implementation is still WIP and should land in the new 2.2 beta very soon. In the meanwhile did you check if enabling "allow network scan" in the Sonos provider settings makes any impact ? I believe HA has that one enabled by default (and we dont)

Sorry, missed this question. Yes it is/was on: CleanShot 2024-08-21 at 13 36 58

Issue still remains. CleanShot 2024-08-21 at 13 38 01

HA-TB303 commented 1 month ago

Just tested this again. Starting point: image When I disable the 'logeerkamer' speaker (a Sonos roam, which is currently switched on) and found in the Home Assistant integration, but NOT in MASS) and then enable the speaker again it works. CleanShot 2024-08-22 at 18 01 21 CleanShot 2024-08-22 at 18 01 42

OzGav commented 1 month ago

Please confirm this has been fixed with the release of the new Sonos provider in 2.3.0 beta 3

HA-TB303 commented 1 month ago

Hi, Im running version: 2.2.2 (no beta). Does that contain the fix?

OzGav commented 1 month ago

@HA-TB303 No it is beta only

HA-TB303 commented 1 month ago

Hi, it's not fixed in beta. Some result.

Starting point: CleanShot 2024-08-24 at 10 46 10

I then switch on the Sonos Roam (logeerkamer). Nothing happens, HA and The Sonos App have allready detected the speaker. Only when I refresh the page above, I get: CleanShot 2024-08-24 at 10 48 14

I then try playing A Song from YouTube Music to the "Test Group" which contains the Sonos "Kantoor", "Keuken" and "Logeerkamer".

It does not work (on any speaker).

So I turn off the group: CleanShot 2024-08-24 at 10 50 48

And then play to the "Logeerkamer" (sonos roam) only:

That works.

The speakers availability and grouping works fine from Home Assistant and the Sonos app.

So it's still pretty much unusable :(

HA-TB303 commented 1 month ago

I forgot to mention that when tuning the Sonos Roam (logeerkamer) off, this is not detected at all by MA in contrast to the HA integration that has the updated state right away. CleanShot 2024-08-24 at 10 59 03

HA-TB303 commented 1 month ago

Same thing when turning the speaker on again: CleanShot 2024-08-24 at 11 00 51

From the MA point of view the speaker was never switched off.

HA-TB303 commented 1 month ago

Maybe park this issue until this is implemented? https://github.com/orgs/music-assistant/projects/2?pane=issue&itemId=59022273 and then retest?

OzGav commented 1 month ago

@HA-TB303 That has been completed. Please check if this is still an issue with 2.3.0 beta 6 (or above)

HA-TB303 commented 1 month ago

Hi, I repeated the same test with 2.3.0b6. When switching the Sonos Roam off, this is noticed right away.

I then turned it off, waited 3 minutes and refreshed the page, but the speaker still appears online.

I then turned it on again and played some song to the test group (which contains the sonos roam). This now works.

When then again switching the Sonos Roam off, it still appears online in MA. Even after 3 minutes and refreshing the UI.

OzGav commented 1 month ago

OK that doesn't seem to be related to your intial report. The initial report is about speakers being unavailable. If that aspect is fixed then this report can be closed.

Players taking a little time to be detected as offline is to be somewhat expected.

OzGav commented 1 month ago

@HA-TB303 Is the topic of your original report resolved or is it covered by one of the other open issues?

HA-TB303 commented 1 month ago

I have to retest with the lastest version, but I am abroad now and not able to retest before Wednesday.

HA-TB303 commented 1 month ago

Hi, yes this seems to be resolved!

marcelveldt commented 1 month ago

OK great, so the original issue is resolved now with the new S2 provider. Now just focus on the handful of leftover issues with that, such as the battery powered speaker going online-offline-online you reported.