Hubitat Sonos Integration

Hello,

Ive recently set up some sonos speaker and would like to control them via hubitat's built in sonos driver.

Now when I click on my speaker in devices there are a bunch of possible commands. Play, pause, text etc work well. However I would like to play a track or set a track on spotify and this doesnt work. I'm using track links directly from spotify but nothing seems to happen.

What am I doing wrong?

Best regards

If you start what you want playing from the Sonos app on the Sonos speaker in question then go into the Device tab for that Sonos speaker and look for the State Variables URI that value is what you would use in the set track field to change to that song/station via a rule.

Thanks for the hint....this doesnt work either though. It shows a value like "x-rincon-queue:RINCON_347E5CF3DA6401400#vli"....when I paste this in the play track field and press play nothing happens.....

I don't think the HE integration is using the Sonos API. If not then many online services will no longer work because of changes made by Sonos in their updates. This is from the python soco package that I've used and it also affect the node.js projects out there as well

Src: GitHub - SoCo/SoCo: SoCo (Sonos Controller) is a Python project that allows you to programmatically control Sonos speakers.

Sonos has changed the way music service account information is available. This means that currently a group of music service will give authentication issues and cannot be used at all . Known members of this group are: Google Play Music, Apple Music, Amazon Music, Spotify and Napster.

Thanks @jeubanks. I've only ever tried local music from my server or Pandora and both those work and I wasn't/am not home to try Spotify.

I had hit or miss results with different spotify URI's and Google Music URI's trying to play them local. As a result I've started developing against the Sonos API directly which doesn't have that problem but it is cloud based but so is the music so it doesn't really matter.

I managed to get a song played on my speakers. Was using the wrong link. However I was hoping for the spotify app to see my sonos speakers connected (as an active spotify connect device). This isnt the case though.

Is there any way to control spotify connect for my sonos speakers?

So far I have found out that the spotify api doesnt support sonos. So it would have to be a different route.

Can the app be controlled by intents?

I really really would love to control which spotify connect device is being used....

I had Spotify premium for a few months and I'm pretty sure I could play music directly on my Sonos speakers from the Spotify app when my phone was connected to the same network as the Sonos speakers, I'm pretty sure it was limited to paid subscription users though, and it's possible I'm remembering it wrong as that was about a year ago.

I know it's possible from within the app. I'm talking about automation here though. Via hubitat/sonos api/spotify api or something else....maybe intents with tasker? I haven't figured it out yet....

Not sure about the HE integration. However the way I do it through the API is by adding the spotify station to my sonos favorites. Anything you add to your sonos favorites can then be easily played.

When you play your favorites through the api does it show the sonos speaker as connected in the spotify app? Because this is what I am aiming for. I need the spotify app to connect to my sonos speaker so that I can search and play tracks right away without having to chose the spotify connect device everytime....

I'm a bit confused. You first said you wanted the integration for "Automation" but now you're talking about using the Spotify App from your phone to choose and select things. Which are you looking for? A way to automate playing music or a User Interface which you already have via the App?

Sorry yeah it seems confusing. I'm using the spotify app on my dashboard to play my music. What I am looking for is an automation which picks a spotify connect device and streams to it.

This can be done with the spotify api. However apparently the spotify api doesnt support sonos. So I was wondering if I could somehow activate the sonos speaker via the sonos app or maybe hubitat by streaming a spotify song to it.....it seems however the app doesnt recognize that music is streamed to my sonos speakers as it doesnt show the device as "active".....so far I can only think of autoinput to push all the necessary buttons to connect a device....but thats quite unreliable....

I have no idea what Spotify app on what dashboard you're referring to.

Spotify doesn't know about Sonos as far as I know of. However Sonos does know how to play a URI from Spotify. I think you need to change your focus of trying to get Spotify to play to a Sonos speaker and let Sonos play the URI from Spotify if you want to automate this.

If you use Node-Red you could use this flow.

I use Hubitat to call the Local end point (in yellow), which then plays Fleetwood Mac on my office Sonos speaker. (Technically it plays the queue, but that's always Fleetwood Mac).

FYI, the local end point is the Node-Red-IP:port/WhateverYouWantItToBe

The node in yellow has a input box that you type: /WhateverYouWantItToBe
The local end point called by Hubitat is: Node-Red-IP:port/WhateverYouWantItToBe

The flow is not mine, but readily avavaible within the palette. The Trigger took a little bit of working out though. I can provide more details if anyone is interested.

Edit: I first got into Node Red via @corerootedxb 's thread here

It's a deep rabbit hole

3 Likes

It works for me. I just pasted...

x-rincon-queue:RINCON_7828CA98DF0C01400#0

... into the "Play Track" option on the device page (which I copied from the uri data displayed on the device page while playing via Sonos app)

...and it plays one of my favourite current albums!

So cool!

Another example, a gym music radio station from TuneIn plays fine.

aac://http://5.135.183.124:8256/stream

The process is start the music from your Sonos app in the normal way outside of Hubitat. Then go into Hubitat device page for your Sonos and capture the test in the "uri". That's what you can then re-use into the "Play Track" option or using RM.

Do you have any code using the Sonos api that you could share?

Code for what? Hubitat? Sorry no.

What kind of functionality are you looking for? And which API are you referring to?