Sonos playlist bug?

Hi,
I have a problem found to play a playlist on my sonos speaker. I’m using this code:

serviced: media_player.play_media
data:
  media_content_id: ddf_1
  media_content_type: playlist
target:
  device_id: fd82877b7e5e320c1584d9f6c04f9d10

and that works fine.
But I have more than one playlist stored in my sonos system, all created in the same way with the same pattern and so on. But when I try to start ddf_2 I get this message in my logs:

2023-09-24 09:54:29.506 ERROR (SyncWorker_13) [homeassistant.components.sonos.media_player] Could not find a Sonos playlist named "ddf_2"

And now it’s going crazy.
The following list are playable:
ddf_1
ddf_10
ddf_100 to ddf_1xx

When I’m trying to start ddf_11 I get


2023-09-24 09:57:00.397 ERROR (MainThread) [homeassistant.components.automation.neue_automatisierung_2] Neue Automatisierung: Error executing script. Error for call_service at pos 3: Error calling SonosMediaPlayerEntity._play_media on media_player.schlafzimmer: UPnP Error 804 received:  from 192.168.145.16
2023-09-24 09:57:00.406 ERROR (MainThread) [homeassistant.components.automation.neue_automatisierung_2] Error while executing automation automation.neue_automatisierung_2: Error calling SonosMediaPlayerEntity._play_media on media_player.schlafzimmer: UPnP Error 804 received:  from 192.168.145.16

So most of them ends up in the “not found” error.

I can only play ddf_0, ddf_1, ddf_10 and ddf_100->ddf_199

What is the magic trick to get this work? Or did I found a bug?
Cheers and thx
Marco

Hello Namesake,

Sonos is currently having some kind of problems, the week all favorites were unavailable in the Sonos app for me and no services were available either. Since yesterday, however, it works again with me.
Curiously, not all users were affected, with some it worked, with others again not.
So does not hang on Home Assistant. Have you ever started the original Sonos app and tried to start the playlist?

Greetings
Moss

Hi Moss,
many thx for your reply. Sure, I can easily start all playlists wir the sonos app. Also dff_2 and so on. All that are not working with the script are working by playing them with the sonos app.
I have also my old Redmatic instance where I had this already implanted and I’m able to play all dff_x playlists with that.
So i guess that not sonos but the way how the sonos implementation on Home Assistent is trying todo this.
Don’t you agree?
Cheers
Marco

Ok then I was unfortunately wrong with my answer
Unfortunately I can not help here

Greetings Moss

You are totally welcome. I also wondering why this is happen and hope to find an answer in this forum. Or is there a way to open a bug ticket answer? Maybe it’s truly a bug and the developer are able to reproduce them?!

Maybe I found the problem but not a solution.
In the Logs I can see that there are only the items from 0 to 100 are requested:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
	<s:Body>
		<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
			<ObjectID>SQ:</ObjectID>
			<BrowseFlag>BrowseDirectChildren</BrowseFlag>
			<Filter>*</Filter>
			<StartingIndex>0</StartingIndex>
			<RequestedCount>100</RequestedCount>
			<SortCriteria/>
		</u:Browse>
	</s:Body>
</s:Envelope>

but I don’t know where to change or where to implement a loop if needed to be carried in chunks.
Maybe any ideas?
:smiley:

Ok, I fixed this by a little cange in the media_player.py file.

Line ~632: (old)

            try:
                playlists = soco.get_sonos_playlists()
                playlist = next(p for p in playlists if p.title == media_id)

(new)

            try:
                playlists = soco.get_sonos_playlists(complete_result=True)
                playlist = next(p for p in playlists if p.title == media_id)

This change the behavior that all playlists are downloaded now and can be used.
But sorry, I don’t how to open a feature/change request here. So maybe someone find this post helpfule and can made this for me or someone can help me to create one :slight_smile:
Cheers
Marco

Fix is discribed here: Help needed with max_items in playlists · Issue #949 · SoCo/SoCo · GitHub
Many thx to pwd.