Where to get URI for Sonos?

I'm new to Hubitat. I've managed to port over my entire SmartThings/WebCore system, and everything works EXCEPT anything related to Sonos. The Hubitat developers have clearly spent 99% of their efforts on Speech Synthesis for Sonos. It seems that's all I can do!

I want to play music from a Rule. Preferably a playlist. The Hubitat integration requires a URI to be passed into the "Play" command.

Where can I find the required URI?

Look under the state variables on the device page. Here is an example of one of our speakers that was recently playing my wife's Pandora playlist.

From what I can tell I can only get this x-rincon-queue URI. A bit of googling tells me that this refers to Sonos' internal queue as opposed to any identifiable playlist. It's actually an Apple music playlist, but nothing in this JSON refers to apple music.

In the dashboard I use a button with device set to app and link url to....
Sonos://

Opens the native Sonos app perfectly.

Could you elaborate on what you mean? In my dashboard I can see this:

The URI is a link to open the actual Sonos App

Its the TrackURI I need for the playTrack() function. Except I'm looking to play a playlist not a track. But I can't find out what the URI is of the playlist I want to play.

The URI process is a search and try method using a browser. There are a lot of services, with varying results - so good luck. I do not have a list of these, but they are easy to find (i.e., radio.com, etc).

For my Samsung WiFi Speakers, the below is a list of verified sounds - just a start. Note that these url's point to some of the many on-line services.

[title: "Bell 1", uri: "http://s3.amazonaws.com/smartapp-media/sonos/bell1.mp3", duration: "10"]
[title: "Dogs Barking", uri: "http://s3.amazonaws.com/smartapp-media/sonos/dogs.mp3", duration: "10"]
[title: "Fire Alarm", uri: "http://s3.amazonaws.com/smartapp-media/sonos/alarm.mp3", duration: "17"]
[title: "The mail has arrived",uri: "http://s3.amazonaws.com/smartapp-media/sonos/the+mail+has+arrived.mp3", duration: "1"]
[title: "A door opened", uri: "http://s3.amazonaws.com/smartapp-media/sonos/a+door+opened.mp3", duration: "1"]
[title: "There is motion", uri: "http://s3.amazonaws.com/smartapp-media/sonos/there+is+motion.mp3", duration: "1"]
[title: "Someone is arriving", uri: "http://s3.amazonaws.com/smartapp-media/sonos/someone+is+arriving.mp3", duration: "1"]
===== Some working Streaming Stations =====
[title:"Cafe del Mar", uri:"https://streams.radio.co/se1a320b47/listen", duration: 0]
[title:"UT-KUTX", uri: "https://kut.streamguys1.com/kutx-web", duration: 0]
[title:"89.7 FM Perth", uri: "https://ice8.securenetsystems.net/897FM", duration: 0]
[title:"Euro1", uri:"https://streams.radio.co/se1a320b47/listen", duration: 0]
[title:"Easy Hits Florida", uri:"http://airspectrum.cdnstream1.com:8114/1648_128", duration: 0]
[title:"Austin Blues", uri:"http://158.69.131.71:8036/stream/1/", duration: 0]

I use the playTrack command to access the aforementioned playlist. Below is the exact execution of a button on my SharpTools dashboard that allows my wife to easily trigger her playlist.

Unfortunately the JSON data doesn't give me a URI for Apple Music. The provided URI on my data refers to the internal play queue on the Sonos Device.

I use the node-sonos-http-api to augment the built-in integration.

You have to run in on another computer that can run nodejs (which is basically anything).

You could use it temporarily to pull URIs for various tracks or playlists. Or you could use it permanently to play favorites and playlists, as well as grouping and playback control.

In the end, I use the built-in app for TTS only and node-sonos-http-api for everything else Sonos related. I have it running on a Raspberry Pi on my network.

1 Like

Here's a little helper integration that I wrote if you end up using the node-sonos-http-api full-time: Control Sonos Music in 2020? - #26 by tomw

Thanks I'm going to look into this when I have time. There's a Docker image for node-sonos-http-api that I can install on my Synology NAS. Just need to figure out how to configure it and interact with it.

There's an API reference that gets served from the device you host it on. In my experience, that interface is a little bit out of date, though it works well for the main functionality.

image

You can also consult the long readme on GitHub to get a more in-depth and complete description of the available API entrypoints.

1 Like

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