Sono Integration: How do I play music from HE to Sonos?

@homeauto2112,

I suppose your profile picture doesn't help figuring the intent... LMAO

The current node-sonos-http-api doesn't provide a search function like the Echo Speak does. As I think about it a bit more, you might be able to use a GV with a connector (HE) to create a text input on a dashboard. You would then have to dig into the Sonos API to see more about their search functions. They are reported to be building a new cloud API which we will be stuck with once the deprecate the local one. This is completely off the top of my head and may be wrong, but it is a direction.

2 Likes

Correct. As I mentioned, I just it play my favorites, set volumes, join speakers etc. I apologize if I gave the impression that it can be used to search for music.

No apology need there my friend. I'm just trying to figure out a way to do that. It would be really cool to use a dashboard button to search (e.g. like using the search dialog on the Sonos App). Just thinking out loud :slight_smile:

Yup. 100%.

Echo speaks allows for [written] keyword searches within music streaming services. That is a great feature that should be implemented (unless this is one of the things that makes echo speaks so unstable and crashes the hub lol)

Not sure how the search function in Echo Speaks works but there is a search function in the node-sonos-http-api

1 Like

I stand corrected. This certainly seems doable with global variables.

2 Likes

okay...Here's what I have so far. I created a variable called music_search and then created a connector for it. I put it on the dashboard and then created a rule to add a plus when more than one word is typed into the box. I can't seem to get the http line to accept the variable.


20%20PM

Any ideas?

@bravenel Maybe you can help clarify something for me. In the rule above, I am putting a GV in the http line. When I look at the logs, shouldn't it show what the GV is? Every other GV shows it's contents in the logs (e.g. notifications). I'm sure it's something obvious, but I'm just not seeing why this isn't working.

Notice that what is logged is the same text that is displayed in the rule summary you showed above. The same facility is used to generate both, so it does not show the replaced value of the variable in the logs. You could show it in the logs by using a Log Action, such as

Log: Music search = %music_search%

As an action in the logs, that too would show %music_search%, but the actually output of the log action would show the replaced value. Or you could log out the full URL with the Log action.

And it does:

Is there a way to compose that http line with the contents of the variable? I was approaching it like the log entries accompanying the notifications. Obviously this is very different.

The actual http that is sent has the replaced variable in it.

I was hoping you wouldn't say that. That means it's the Sonos API that's not receiving it properly and now I have to go learn how all that works.

Thank you for the unbelievable response speed wise!

It does the full replacement of the URL for everything formatted %something% as the parameter passed to asynchttpGet.

You could easily do a little experiment (not with Sonos) to convince yourself that this is actually happening. You can use that website that shows what you send in Gets and Posts sent to it.

@bravenel Well, I am running the node.js on a Mac and I setup tcpdump to watch for incoming traffic from the HE hub to trying to emulate your experiment.

When I use any of the commands I have programmed, I see traffic between the HE and my server. All seems to work well.

When I include a % as a variable indicator no traffic is seen coming into the server. The only time it does is if it's followed by a 20 (as in %20 to denote a white space).

No incoming traffic from the hub to the Mac. As soon as I remove the % in any string of an HTTP GET, there is traffic between the hub and my Mac.

21%20PM
04%20PM

When I ran the rule above, you can see in the second pic that the Room/clearqueue made it to the server. The following command with the % wrapped around the variable never left the HE.

Okay. I finally got it working. The glitch seems to be when using a two word phrase for the Sonos location. For example, HE doesn't send anything when it's /Family Room/ or /Family%20Room/. If I use a single word, such as Office, then the URL is sent.

HE Sends:
http://192.168.5.220:5005/Office/musicsearch/apple/song/%music_search%

HE Doesn't Send:
http://192.168.5.220:5005/Family%20Room/musicsearch/apple/song/%music_search%
http://192.168.5.220:5005/Family Room/musicsearch/apple/song/%music_search%

I have three rooms with two word names; Guest Room, Family Room, Music Room. If I try with any of them in the above "Doesn't Send:" section, the results are the same.

Hello.
My apologies for reviving an old thread.
Just a quick question.
(I'm just about to install a full Sonos installation at someone's house, and I really don't know too much about it.)
Why would I want to do something custom from Hubitat, instead of using the Sonos app directly?
Isn't it very good? Doesn't it allow you to do searching?

If the goal is searching for music and playing it manually, then use the Sonos app.

But Hubitat makes it possible to play (or search for) music based on all kinds of triggers, or send TTS notifications to speakers, probably other features but I’m not much of a Sonos person myself so I don’t use the integration extensively.

1 Like

Hello all, just got a couple of Sonos speakers and have added the integration to my hub.

A bit of background; I'm coming from Google Home Minis. We wanted something that sounded better and also something that didn't have a microphone (all of our mics on the home minis are muted). I went to Ikea and picked up 2 of their Symfonisk speakers. SO far, OBVIOUSLY a huge jump in quality from the Home minis.

One of the things we loved about the home minis was the ability to have a morning routine that plays the news. They would play the latest news from a bunch of our sources, most of them updated hourly.

I've gone and tracked down all of the RSS feeds for most of those sources. Now I' trying to replicate the capability I had through the Sonos Speakers an Hubitat.

I'm goign to try to explain this problem but because I don't understand it fully myself, it may sound a bit disjointed. Apologies in advance.

Here is the link to one of the casts I am trying to integrate.

https://www.cbc.ca/podcasting/includes/hourlynews.xml

I'm not terribly familiar with RSS or Sonos, but when I plug this link in, nothing happens, however, when I plug the link that is ON that same XML file, the cast plays. The problem is that the XML file is updated daily, but the file name is of a particular cast for a certain date.

Anyone know how I would get this to work? Then I imagine, I can simply apply that same solution to the rest of the news casts.

Thank you,

Phil