Hubitat Sonos Integration

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?

The hubitat sonos integration does not work very good. IFTTT has a function to play favorites on sonos. This does work. I would like to be able to play a favorite from the sonos ones available from hubitat directly to sonos.

That's a reasonable thing to want to do, but I think that reprogramming it yourself from scratch will be a lot of work.

You might want to use something that already exists to get you started faster. I prefer the node-sonos-http-api: GitHub - jishi/node-sonos-http-api: An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.

The downside of that approach is that you need an external machine, but it runs well on a Raspberry Pi that you might already have.

Thanks - I saw that, I might try that. Was hoping to find something that ran native

Depending on your definition of "native", this cloud-based set of APIs could also do the trick: https://developer.sonos.com/reference/control-api/favorites/

1 Like

Yep, what I was looking for is some groovy code running on hubitat or smartthings that implemented some of that. Not sure what the sonos integration app on hubitat uses, but it does not work very well. It must use the undocumented local lan interface because it doesn't require any login to sonos.

You might like to look at the node red sonos implementation. It's pretty good, and doesnt require any login to sonos, although you do need to specifiy IP adresses.

I haven't been able to get the Sonos Integration to even install (I think). After you click "add Built-in app" and click "Sonos Integration" in the "Install New Built-In App" dialog it goes straight to "Discovery Started!" and then can't find my Sonos. No indication that anything's actually been installed...

Are your Sonos speakers on the same VLAN (IP range) as your Hubitat hub? What kind of speakers do you have? I know they recently made a change to try to address issues with the Symfonisk speakers I think that was in the latest firmware. Sonos speakers can also be added manually if you find all the IP addresses for your speakers. Either way you will probably want to setup a DHCP reservation for each speaker to keep the IP from changing.

2 Likes