Querying a useful URI for Sonos Preset app

Hi @stephack,

Been playing with your Sonos Preset App.. as in ABC.. thank you for your contributions to the community! Got a question.. is there a definitive way to get a proper usable URI to add to your preset array? You did seem to allude in another thread that the queries through "Recently Played URIs" could be hit or miss. In particular when using Spotify, I seem to get the same exact URI no matter what the content (but it can determine the playlist name).. see below:

####

Recently Played URI's

1. Station Type=Sonos Q Daily Mix 2

x-rincon-queue:RINCON_48A6B820FEBA01400#0

2. Station Type=Sonos Q Daily Mix 1

x-rincon-queue:RINCON_48A6B820FEBA01400#0

3. Station Type=Sonos Q old school

x-rincon-queue:RINCON_48A6B820FEBA01400#vli

I can however secure an explicit, usable URI when using TuneIn:

x-rincon-mp3radio://http://rfcmedia.streamguys1.com/70hits.mp3?source=TuneIn&aw_0_1st.playerid=Sonos&aw_0_1st.playerid=Sonos&aw_0_1st.skey=1580015632&aw_0_1st.skey=1580015632&aw_0_1st.premium=false&aw_0_1st.platform=tunein

In both cases when I'm querying the URI, I'm summoning the Sonos play instructions through the Sonos app on my phone (and not the service's app itself). With spotify there is no difference in returning the URI.. but for TunedIn.. it makes all the difference in a usable URI if I solicit the playlist through the Sonos App.

Any ideas? Thanks again!

best,

Andrew

I honestly can't remember the details from my testing as I dont use Spotify. I worked with someone on the forum to try to figure out the Spotify puzzle but we didn't get very far. I cant even remember what spotify calls their various options but I believe we got "radio stations" to work but not "playlists". Spotify does some really funky stuff with their Sonos integration (probably intentionally) that makes it difficult or, for someone with my level of knowledge, impossible to extract a usable uri.

Others have had greater success using the Sonos http api. It requires a separate device (rpi or otherwise) to run the api server but it gives a lot more options than the HE integration does. If you are familiar with Docker, there is even a container for it so it can be spun up pretty easily.

1 Like

Hey @stephack,

Thanks for the response.. makes sense on the Spotify encumbrances... by chance, what service did you use/test your uri calls against w/ Sonos?

I am new to Jishi's Sonos Http API.. and have not done any code editing on this platform.. but basically I should set up the Sonos API via Docker on a Raspberry Pi.. correct? any basic newb docs out there you could point me to to get started?

thanks so much!

+1 as someone who would like to know a reliable way to set a station or radio station on any service for Sonos (pandora, amazon music, spotify, Sound cloud, etc. I'm easy).

I used TuneIn, Amazon Music and Google Play Music. For each service they may use a different URI depending on the type of music being played (Radio Station vs Playlist vs More Like This, etc). That was why my app gave multiple options to try. Getting this working requires a bit of trial and error but once you find the correct URI it usually works consistently.

For the Sonos Api server there are a couple of threads in the forum with details. I don't use Hubitat or the Api for my Sonos anymore so any pointers I give would be based on memory and outdated. Setting up from scratch was fairly simple if you follow the Readme on Jishi's github but docker is very easy as well if you are already familiar with containers.

I believe @homeauto2112 and @aaiyar use the Sonos Api extensively. Hopefully they can get you going.

I don't use the Docker version, but you can certainly do that. In any event, once it is setup, it will be listening on TCP port 5005 (unless you configure it to listen elsewhere). You'll need to edit the default "settings.json" to match your Sonos setup.

I have 2 Sonos One in a group called Bedroom and a PlayBar+Sub in a group called LivingRoom (I recommend you not have spaces in your Sonos speakers names). Here's what my settings.json looks like:

{
  "all": {
    "playmode": {
      "shuffle": true
   },
   "players": [
     {
       "roomName": 'Bedroom',
       "volume": 15
     },
     {
       "roomName": 'LivingRoom',
       "volume": 15
     }
  ],
  "pauseOthers": true
}
}

And you're on your way. I start my favorites using @ogiewon's http-momentary-switch (it's on his Github) to create virtual switches that I use in my rules etc.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.