jishi / node-sonos-discovery

Simplified framework for Sonos built on node.js
MIT License
146 stars 75 forks source link

GetFavorites does not return all favorites #122

Open kshartman opened 1 year ago

kshartman commented 1 year ago

I have a couple of Sonos Radio HD favorites but the GetFavorites method doesn't return them so I can't use them as presets in node-sonos-http-api. It calls a method browseAll("FV:2"). I looked at the Sonos S2 API and it says that FV:2 will return up to 70 favorites (I have less than that) but it seems it won't return these two. In the debugger I tried calling the same method with R:0/0 which is supposed to return radio stations. It doesn't return these either. Am I missing something, or is this just an omission in the Sonos Controller API? I don't see any way to get to them. This using an S2 system. I have 2 systems (households?) on the same account, but I don't think that's related. Running Ubuntu 22.04 LTS on intel hardware. The API runs in docker but that makes no difference because it does the same thing when I put in Visual Studio Code with npm start outside docker.

jishi commented 1 year ago

I don't have an S2 system so can't verify your findings.

How may favorites do you actually receive? And where did you find the documentation about the 70 favorites? The Sonos UPnP API has never been publically documented afaik.

Since the offical apps is using the same UPnP API, I don't see how it would have been omitted by them, there is probably some fault at play.

kshartman commented 1 year ago

You are correct, the document I was looking at is called the Sonos Control API not the UPNP api. Nevertheless it seems to closely correspond to what you call (except for the houseHoldId). The document is here: https://developer.sonos.com/reference/control-api/favorites/ . That is where it states "Use the getFavorites command in the favorites namespace to get the list of Sonos favorites for a household. The player limits the number of Sonos favorites to 70". I haven't actually tested if there is a limit because I only have 20 favorites. I will investigate and get back to you.

The other document I was looking at it is not official: https://svrooij.io/sonos-api-docs/, It does not mention this limit. But that is where I found the explanation of the FV:2 parameter for content browsing (https://svrooij.io/sonos-api-docs/services/content-directory.html). When I debugged your code it never seemed to return the Sonos Stations. Just the Pandora stations. But when I looked at the app just now and added a Sonos Radio HD station back, the display seemed different than what I remember. I will try adding a preset again and see if t works,

I never had an issue with a preset accessing a favorite before until I purchased Sonos Radio HD. I added a couple of favorites. Your code never returned them - just the pandora stations, the albums, playlists and so on.

I will try again in the debugger. Perhaps I was mistaken or the recent app update changed things. I will let you know.

kshartman commented 1 year ago

Yeah I can confirm the S2 system does NOT return Sonos HD Radio Favorites. This is what it gets from my system:

["Aardvark Blues FM","Ambient Radio","An African Night","Archaic Beats","Baroque Radio","Blues Acoustic","Blues Chicago","Blues Electric","Christmas Traditional","Classical 101","Country Outlaws","Crickets Summer Night","Dark Ambient Radio","Electronic Radio","Galactic Caravan","Gangsta Rap Radio","Hearts of Space","Houston Blues Radio","Imported Playlists","KERA","Radio Paradise Eclectic/World Mix","Sahara Sunset Radio","Smooth Jazz","SomaFM: Boot Liquor","SomaFM: Christmas Lounge","SomaFM: Deep Space One","SomaFM: Drone Zone","SomaFM: Heavyweight Reggae","SomaFM: Secret Agent","This Weeks Show","Thundering Rainstorm","Toad Trills and Thunder","Trending Now"]

It does not contain "Chill Beats" which is a Sonos Radio HD station favorite. At least I marked it a favorite. But when I look at My Sonos, all the things which are stations in the list above are in Stations (all favorited) but Chill Beats is not. Sonos Radio Stations are in the list but Sonos Radio HD Stations are not. Chill Beats shows up in a different list called Sonos Radio HD Favorites. Nothing in that list is returned for the FV:2 call. I have one unit in the house with voice control, a Sonos Move. If I tell the move "Hey Sonos, play Chill Beats" it works.

I will investigate further. As you noted there could be another "undocumented" api feature or its a bug. My bet is on the former. I will have to dig out the packet sniffer probably.