How to play chosen music through Sonos player


(Daisy Daisy give me your answer do) #1

This has been bit of an issue for me as I could not work out what you needed to enter in the ‘Track URI’ field in order to play specific music. In my case some classical piano music when going into the bathroom and motion is detected… I’ve set myself up there for a joke there haven’t I!

Anyway, I had no problem with playing what was currently being played but to select a chosen track, playlist or radio station I could not find out how to do it.

I have now, at long last found a solution, so i’m going to share with you my method of getting this to work. Hopefully this will help somebody else having the same issues:-

a) Find out the IP Address of your Sonos player. I located this by accessing my router and viewing the list of connected devices.

b) Open your browser window and type in the following URL substituting the ###.###.###.### with your IP Address:-

http://###.###.###.###:1400/status/perf

c) The web page shown gives you information about what your Sonos is doing. Look down to where the text ‘AVT Play Log:’ is shown and directly below is a line of text starting with ‘currently:’ followed by current state e.g ‘PLAYING’. It is the remainder of the text in this row which is the track currently being played and needs to be copied into the ‘Track URI’ field.

d) Using your Sonos controller app select your desired track, radio station or playlist, copy the remainder of the text in this row and then paste into the Track URI field of your CoRE action - ‘Play track’.

There you go. I hope that helps someone.


Help with BBC Radio 2 URI for playing on SONOS with CoRE
(Bob) #2

This is a fantastic bit of information.
I now need to find a track and save it to my Google Music playlist, play it and then look in the log.
Guess what the track is going to be in honour of your digging around and sharing this information…
.
.
Scroll Down.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.Keep scrolling
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.



DAISY DAISY GIVE ME YOUR ANSWER DO. :slight_smile:


(Daisy Daisy give me your answer do) #3

Well after all that excitement from last night I can’t seem to get it to work on the Sonos in the Bathroom. It does work for the Sonos in the Kitchen and if I duplicate the action in the same piston for the Bathroom, it works in the Kitchen, but not in the Bathroom. Go figure???


(James T) #4

@Hal9000 this is great, but I think I found where it went wrong, and I found an easier way to get the right URI.
In the Sonos app, play the track/playlist/radio station that you want (I wanted to set a TuneIn radio station).
Go to the IDE -> Devices and go into you device. Scroll down and you will get the right string to use - ‘trackUri’ is the string that needs copying ( you mentioned the string after CURRENTLY directly below ‘AVT Play Log’).
This string is what needs pasting into the CoRE ‘Play track’ piston. In the pic below, the line called ‘uri’ is the string you mentioned above. When I used that (I created a test piston that changed the station when a test routine was pressed) the first time I pressed the routine the radio station changed to CapitalFM from Kiss FM but it only lasted 10 seconds then switched back to the Kiss FM. Pressing routine again didn’t switch to Capital FM.


(Daisy Daisy give me your answer do) #5

@Townsmcp sounds like it is not working consistently. Thanks for the alternative anyway. I did try creating a piston that would save the trackUri to a variable but I found that this field would be null (blank). I did save trackData to a variable and I did see all that detail saved to it, although I’m sure I then tried to write the variable back to the field and it didn’t work. I’ll give it another try.

I also found my original method would not work with google play tracks, but only with radio stations. I wonder if more data is required in the other fields to do this.


(James T) #6

This is working every time when I use the text from trackUri instead of uri.
I’m getting the same problem when trying to use a piston to store the trackUri as a variable too - comes out null. However as I only use a bunch of radio channels that I want the Sonos to switch to I have created the global variables by hand and populated with the right text.


(Dale C) #7

I think this applies to what I am trying to do but I am not sure where I am to make the necessary mods?

I have several custom mp3 files that I want to have play through my Sonos speaker based on a simple switch trigger like that of a door opening will play one. Where do I actually make the necessary changes? I think it is in the Sonos smartapp


(Daisy Daisy give me your answer do) #8

In order to play your custom MP3 files I believe you will have to make them playable from a URI address. I tried to upload some MP3 files to my google play account and then play the stream from there but no success. If you are playing the MP3 files from a local server, you may be able to use the resulting track URI, if Sonos creates one. I have not tried this but worth a shot.


(James T) #9

I think Ines of the easiest ways for this one would be to play the file in the Sonos app, then go to the IDE while the MP3 is playing, copy down the address trackURI for the song and manually save it as a global variable in CoRE. That way you can reference the variable to play when you want it


(Adam Davidson) #10

This doesn’t seem to be working with Apple Music tracks.

The URI I have is “x-sonos-http:librarytrack%3ai.89654.mp4?sid=204&flags=8224&sn=1”.

if I put that into CoRE, it does nothing with it


(Mark) #11

Thanks for the help here - I have managed to make this work. Has anyone seen an issue where this doesn’t work if the target Sonos device happens to be grouped with another device? Is there a way to ‘ungroup’ prior to playing the specific stream?


(Stian André Høynes) #12

Seems to work great here!
I suppose there is no way to make a track URI from an entire playlist in Spotify through my Sonos?


(James T) #13

It was working to play a Spotify playlist when I was playing earlier. It works for setting a rdio station too. I slightly tweaked this to then store to a global variable just the URI which other pistons then call e.g. When going to bed to set bedroom Sonos to the correct radio station (to involve this piston I have setup a routine)


(Stian André Høynes) #14

How to you get the URL for a Spotify playlist in Sonos? :slight_smile:


(Alic Chen) #15

Ditto. Tried using both the enqueuedUri and queueIUri and neither one seemed to work. Anyone know how to have it play a specific playlist? Also, it seems like Sonos doesn’t “translate” the URL to display track info. All I see is that it’s playing the a URL. Anyone know how to make this seem more “native”?


(Pieter-Jan Vanmarcke) #16

Anyone found a way to play a spotify playlist on sonos from within webcore at the push of a button?

I already found how I can recall or play the last played playlist, but not how to recall another playlist :frowning:


(Steve Norton) #17

So it seems that a couple of weeks ago Sonos released an update that disabled the internal web page http://w.x.y.z:1400/status/perf due to security measures and wont reactivate them.

So, any ideas how to find out what is currently playing now?


(John) #18

I’m getting track information using webCoRE.


(Andy Hawks) #19

Here are some solutions for getting SmartThings to automate playback of Spotify playlists on Sonos devices:

  1. If you have a Harmony Hub, create Harmony activities for playing your playlists on the Sonos then invoke those Harmony activities from ST (this is the most reliable and close to native solution. It is my recommended solution).
  2. If your Sonos is near a voice assistant, use an ST smart app or webCoRE to have the Sonos speak to Alexa/Google to trigger the playlist (e.g. "Alexa play playlist in the “”
  3. Duplicate your Spotify playlist tracks into a Sonos playlist and play that - ST can play Sonos playlists
  4. Duplicate your Spotify playlist tracks into a webCoRE Piston and use the piston
  5. Use a software tool like TRIGGERcmd that integrates with ST to trigger the playlist from your desktop. Video here: https://youtu.be/5LNVrFHCKkA

(Todd M) #20

Anyone here using Kodi (OSMC on a Raspberry Pi 3) to play music? I do not have Sonos. All of my mp3 files are local. I wrote a very simple piston that uses Kodi as my music player and Speak Text works. But I am having trouble figuring out what the uri is for my local mp3 files so that I can use Play Track.