How to play chosen music through Sonos player

@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.

@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.

1 Like

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.

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

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.

1 Like

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

1 Like

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

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?

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?

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)

1 Like

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

1 Like

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”?

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:

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?

I’m getting track information using webCoRE.

1 Like

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
1 Like

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.

I finally got this to work.

Are you using Alexa to play your Spotify playlists on your Sonos? I don’t have Sonos and don’t use Spotify. But I have been helping someone with Alexa routines and webcore to play his music. He has not been able to get the Spotify playlist thing working yet (with Alexa).

I was researching how to do this also just to simplify my setup. Right now I’m using SonoSequencr along with an IFTTT call with a virtual switch to trigger all my SONOS to play certain music when I get home or in other situations. It works well but there’s a lot of parts there that need to be setup. SonosSequencr is great and if you want deep control, it’s the way to go with or without IFTTT and webCoRE. But, I’ve figured out that if you go into the SmartThings IDE for any of your SONOS speakers, your SONOS favorites are enumerated as Presets in the device details. If you just create a piston in webCoRE to playPreset with a Parameter specified to the preset # of your SONOS favorite, you can kick-off whatever music you want. Seems like a simpler solution and also doesn’t require an IFTTT subscription if you want different tunes to play in different situations…

1 Like