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

I recently decided to give up using Echo Speak and other third party TTS drivers / apps due to their inherent instability and got a couple sonos, which work great with the built-in app.

A great feature in Echo Speak was the ability to search for music based on keywords in, for example, Apple Music.

Is there a way to automate this in the same way with sonos integration? Thanks in advance.

I don't even know how to play music on this device from hubitat... lol IF any good souls wishes to help, I'm all ears! :slight_smile:

I would suggest you do a couple of searches for "Sonos." There is a LOT of info with direct integration and using an API. You won't be disappointed.

1 Like

Maybe my comparison to Echo Speaks was not clear: being able to just input keywords and have HE search AMusic from there, so I could automate music EASYLY, was the meaning of my question.

I guess I will have to work with HE's minimalist integration for I have no time for coding on that one...

Little advise to @homeauto2112 : if you don't know the solution to this problem, please abstain from sending condescending answers. It really serves no purpose. If you know so well your answer, post a link, make yourself useful, not toxic. I know where and how to find the API, code, hack, etc. Not what I am asking for.

@elfege. In the spirit of keeping this community a great place to exchange ideas and knowledge, please don't make any assumptions about the source of someones intent. A simple question regarding someones intent would go a lot farther to making positive connections and clarify things. My answer wasn't intending to be condescending.

My advice stands. While there isn't a direct way to search AMusic from HE, there are several ways that could be used. Your opening post didn't explain anything about your setup, nor did it make any reference to how much research you did. It would be completely asinine for me to tell you how what to do absent any information. Sonos is one of those things that strays into a wide range of custom setups. I have spent a lot of time trying to making this work and I still come up with new ways to think about it.

See Sonos request as an example of how there are still things I am discovering.

Hopefully this clears things up a bit. If you need more help, please explain a bit more and I'm sure we all will try and rally a solution up for you if there is one.

4 Likes

I use node-sonos-http-api to play my favorites. I know there are others using it as well - search the community forums using that as a search term.

1 Like

Thank you so much @aaiyar!

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