Sonos Buttons?

Ahh... Something's off in my media item. I just mapped the rule directly into the dashboard and it works.

In the media tile I've got "Open Hyperlink" for the action and I'm using the $.runRule("foo") but it's not running the rule, I guess?

No.

Can you share a screenshot of the Media Item's hyperlink configuration? Feel free to PM me if you prefer.

One thing to watch out for is making sure it's using straight quotes:

“Bad”

"Good"
1 Like

Try updating the Rule ID with the following tip (source):

Works! Thanks! Looks like it doesn't need to be an actuator @tomw (I changed it back)

2 Likes

Can you share how you did this? I would like to use Sonos directly so I can use my local media, but I never spent much time messing with it in the Sonos app.

I assume he's following the first 3 steps from this post (which sparked the jishi/node-sonos-http-api discussion. :stuck_out_tongue:

1 Like

For this one I just selected a playlist in Spotify in the Sonos app and told it to save to a Sonos playlist. From there I assume you could add other songs to the playlist from other sources.

1 Like

@tomw How would I run presets in the jishi API? Those are outside the particular zone. I want to have a button to run a preset that groups all of the Sonos and sets their volumes, etc. Then have another button that ungroups back to just the one.

Good idea. I hadn't thought of that. I'll need to add the button functionality to the system device as well. Let me think about how to structure that, and then I'll send you something to try.

1 Like

What if the button definitions were up at the system device level as well, then you could choose a zone along with the button number to play it on that zone. That way you don't have to define them on every button device.

Actually, what do you need the Sonos device IPs for for each sonos speaker? Looking at the code it looks like it's for album art URIs but if you get /zones there's absoluteAlbumArtUri properties for currentTrack and nextTrack under both the coordinator and the members of each zone.

Hi,

I am having trouble with the buttons. I added the device and input the node's IP and MAC addresses. But I got nothing return if I hit the "Refresh" button. I went to the Log, and it does show that it interact with the Node server.

What did I do wrong? Refresh doesn't show anything.

Did you do the step to addChildSpeaker? That is where you will see the actual functionality for join/leave, album art (if available), and others. There is a readme with installation and usage instructions in the link that I shared here: Control Sonos Music in 2020? - #26 by tomw

Yes. I did add the child speaker. From the parent device log in HE, I could see it’s retrieving info from http API node. Please see below:

dev:30402022-09-19 02:16:56.319 pm debugresp.data = [[uuid:RINCON_7828CAB4C56E01400, coordinator:[uuid:RINCON_7828CAB4C56E01400, state:[currentTrack:[artist:Richard Clayderman, title:How Deep Is Your Love, album:Ballade Pour Adeline: Richard Clayderman's Best Songs of Love, albumArtURI:/getaa?s=1&u=x-sonos-http%3alibrary%252ftracks%252f349cf8d4-9173-4678-9667-745a6f5f279e%252f.mp3%3fsid%3d201%26flags%3d0%26sn%3d6, duration:227, uri:x-sonos-http:library%2ftracks%2f349cf8d4-9173-4678-9667-745a6f5f279e%2f.mp3?sid=201&flags=0&sn=6, radioShowMetaData:, absoluteAlbumArtURI:http://10.1.1.xx:1400/getaa?s=1&u=x-sonos-http%3Alibrary%252ftracks%252f349cf8d4-9173-4678-9667-745a6f5f279e%252f.mp3%3Fsid%3D201%26flags%3D0%26sn%3D6, streamInfo:, type:track], nextTrack:[uri:x-sonos-

So, it looks like it’s getting info. But child speaker does not get any log. And, I hit Refresh button in parent and child, nothing is showing in device page. Anything else I did wrong?

I installed the driver from HPM, should I copy the code straight from GitHub?

No, installing from HPM should work fine.

Will you PM me that full log output as well as a screenshot of the settings on your child device page(s)? Something may be broken in my logic that traverses the response to try to find the album art.

If you open that absoluteAlbumArtURI in a web browser from a machine on your local network, does it display correctly? What actually shows up on the device page in Hubitat? Feel free to PM me responses to these so we can iterate and debug to figure it out.

I posted v1.1.1 to GitHub and HPM with a fix for this issue.

Thanks for helping me track it down, @roger89.

1 Like

I have 2 HE hubs. Can I have more than 1 webhook statements in the settings.json file? If yes what will the webhook statements look like?

Is it this one?

{
"webhook" : "http://hub1 IP:39501" ,
"webhook" : "http://hub2 IP:39501"
}

Or this one:

{
"webhook" : "http://hub1 IP:39501"
}
{
"webhook" : "http://hub2 IP:39501"
}

You're over on the node-sonos-http-api side now, so I can't speak authoritatively about how it is implemented. But I looked at his code and I think it will only support one webhook host. If either of your examples worked, it would be the first one. Or maybe like this:

[{"webhook": "[http://hub1](http://hub1/) IP:39501"}, {"webhook": "[http://hub2](http://hub2/) IP:39501"}]

But I think you're going to have better luck replicating that attribute sideband somehow from the first (webhook receiving) hub to the second. Like a rule in the first hub that is triggered by that attribute changing and which sends the new value to the second hub using Maker API or similar.