[Nearing Release] Sonos Advanced Controller

Hey Daniel.Winks,

Absolutely on board with the decision to wait for the local transition to be completed before the migration HPM, especially given the upcoming changes. I'd even go so far as to recommend waiting for Sonos Advanced Controller to hit public beta before making the move to HPM; I'm sure there'll be a few hurdles to navigate.

It's fascinating to follow your journey into the realm of local control, and I can't wait for the day when we have a seamlessly functioning Sonos system under local command (except for those Stream Radio station connections, of course).

This Sunday might just free up a bit for me to delve into some testing, and Monday is looking promising too. Given the challenges we've both faced in our setups, it seems like the perfect testing ground. Count me in if you need an extra pair of hands for some advance release testing!

Super pumped about integrating the app into my home production environment full-time. :star2:

Happy Local recoding!

4 Likes

Hi @daniel.winks
I thought I'd give this a go. Here is where I'm at'
I've created a developer account OK and got my Client Key and Client Secret.
I've downloaded 3 files into the library.
I've downloaded the Apps code and OAuth'd it.
I've downloaded 2 driver codes.
I then installed the app and went through the set up by connecting up to my user account and it says my account is connected.
Next I discovered my devices OK (2 of them).
At this point should it define these devices in my device list. I'm not seeing anything new defined.
I do already have them defined using the inbuilt Sonos Integration.
When I click on 'Sonos Virtual Group Devices' I receive this error.

[app:12645](http://192.168.0.24/logs#)2024-01-06 18:40:46.546[error](http://192.168.0.24/logs#)org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[]' with class 'java.util.ArrayList' to class 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Map() on line 409 (method groupPage)

I'm obviously doing something wrong so I was wondering if you could point me in the right direction.
Many Thanks, Bob.

Hey, all new version should be out soon... it doesn't use ANY of that cloud stuff, so there's no need for client key, secret, OAuth, and of that.

Also has a lot of improvements to the player creation and group creation pages.

Give me a bit here and I'll get it posted.

2 Likes

OK thanks.
I'll hold fire until you release your updates.
I'm in no hurry as I have Sonos working up to a point but it is very basic.
I'll go back to my beer and the football (soccer to some). :wink:

Alright everyone, big new release.

First, ALL cloud-related stuff is removed, as everything works locally now. I'm renaming this to "Sonos Advanced" as there's no longer anything "Cloud" about it.

Second, Group Devices have been improved with "switch" capability, and accurately reflect whether the group is "on" or not. I'm working on an improvement to how "Group Players" works, too. Presently, it creates an all new group, with no stream playing. I'll leave this in place as-is. "Join Players To Coordinator" does just that, joins them without interrupting any stream on the coordinator. Also leaving that as-is. But I'm working on a new button, name TBD, that will group all the players together into a new group, and if and only if there's a single stream playing on any one of the players, bring that stream into the new group. If there's 2 or more of the "follower" devices playing, then there's no real way to know which stream to pull in, so in those cases I'll just have it not pull one in.

So if you have "bedroom" and "living room" as a Sonos Group device, with living room as coordinator, and the living room speaker is idle, but the bedroom speaker has a stream playing, there will be a command that will pull them into a group with living room as coordinator still, but rather than being an all-new group with no stream, or having the (non-existent) stream from living room, it'll snag the bedroom stream and move it to the living room when it becomes coordinator.

Similarly, I'll be adding a "Split Group" button that takes whatever stream is playing and starts it playing on each of the members of the group, but with them being a stand-alone coordinator of their one-device "group".

Well, at least I'll add these if functionally it's possible. I'm like 95% sure it is, but I haven't actually dug into it. But it's the next thing I have planned.

I've set up everything on my end for HPM integration, just waiting on my pull request to be approved and merge my repository into the official repository list. In the meanwhile, you can manually add it as a custom repository using this link.

I've also added support for setting bass, treble, and loudness. Looking into being able to set some of the Arc/Beam specific stuff too, as they have a few extra config settings for home theater related stuff. Namely, I want to automate turning "Night Sound" and "Speech Enhancement" on and off. I haven't found where the UPnP control for this exists, if at all, so it'll take some investigation.

I have zero idea whether or not you can in-place upgrade the code... I've got 2 Hubitats, and on my main one, I've only ever had iterative updates as I program things, and on my "testing" hub, I've only tested the all-new all-local version from a "fresh" install via HPM. That said, the way the app works in regard to child devices and their DNIs hasn't changed since I added "current state" a long while back, so it'll probably be OK to update the app/driver code from the old "Sonos Cloud" stuff to the new "Sonos Advanced" ones. But if it doesn't work, then the only thing I can really suggest is just adding "Sonos Advanced" side-by-side to the old app and moving any Rules and stuff over to the new child devices.

This new version uses all-new drivers, and a new app. The old "Sonos Cloud" ones are left in place on GitHub, so if you want to manually upgrade, you'll want to copy/paste in the code from the new drivers and app into your current app and driver code and overwrite it.

Or install the new one side-by-side and move things over... that's probably safer.

Edit: Also forgot, "current state" also now includes "currently playing" album art. Yippie.

5 Likes

So "bundles" are easy to remove. Just click on "Bundles" on the left side of HE, click on the bundle, and at the bottom is a "Delete" button. I don't think deleting a bundle removes any of the libraries, apps, or drivers the bundle installed. So you'll want to go through each of those one by one and remove them, too.

Ok thanks for the headups!

Perhaps a stupid question, but can this work well side by side with the built in app?
Want to make sure playing with this doesn't disrupt my current automations using the built-in version.

And THANK YOU for building this!! The native app is lacking so I also have a bunch of automations that tie into SONOS HTTP running no an rPI to get some of the grouping and join commands working for my needs.

It should be fine. The only thing I can think is that there's probably a limit to the number of "subscriptions" a speaker will allow at once. But since I haven't seen an issue of this, and every "app" does their own subscriptions anyway, I doubt one more will hurt. It should have the same impact on the built-in Sonos app that, say, opening the Sonos app on your phone would cause.

There might be an issue with the built-in one caused by the fact that both use the "magic" 39501 port for routing the "NOTIFY" messages to the app, but I ran both for a while without any trouble.

I've been running just my Sonos Advanced for a while now exclusively. I don't think there's anything the built-in one does that mine doesn't at this point, and quite a lot mine does that it doesn't, obviously.

2 Likes

I think I found a bug. When using the load favorite:

No mater what I select (repeat all, repeat once, none), I'm always getting 'repeat once' which just cycles the first song of the favorite/playlist I chose.

1 Like

Indeed. Looks like I had those still hard-coded from when I originally only had a "load favorite". should be fixed now.

1 Like

Latest version adds an (optional) child device for battery status:


Configurable update interval (since it's polling only, I don't see where battery is exposed as an event, I'll make it event driven if I can find an event I can subscribe to for it).

There's no logic preventing someone from adding a battery status child device to a "One" or a ""SYMFONISK Bookshelf" or any other non-battery-containing speaker. At which point they'll just end up with a blank device that needlessly polls the speaker for non-existent data. I'll have to put in a check to prevent that, but for now at least there's battery stats for anyone who wants it on their Roam, Move, etc.

3 Likes

This is great, really appreciate it. As far as users creating a child battery status device, IMHO you could poll the Sonos device one time to see that the XML battery status data elements are available, as the non battery Sonos devices do not return any XML data…

You are on fire for new features!

Wow, well done. You really are a coding machine!

1 Like

Thank you, can confirm it did.

THANK YOU for this great app, after using the Play text and restore and hearing the music dim down, the word spoken and the music back to the previous state is something I have been hoping for for years now!

Amazing!

1 Like

@daniel.winks - hitting a bug on my first try of using groups.
I created a group that has 3 speakers, initially saw an error in the log but then all of the command now work correctly.

Yay! Amazing!

When I created another "all" group that has 4, ungroup works, but I get the following errors for both the Group Command and the Join Players to Coordinator commands, and nothing changes in my speakers/sonos app unlike the smaller group of 3 that works great:

Only difference is an additional speaker added, specifically a Sonos Amp that controls my outdoor speakers.

I wonder if there's something different with the Amp (which I don't have to test with). At this rate I'm going to end up with a full house of every Sonos product.

I'll DM you here to get some more detailed info for troubleshooting.

2 Likes

This sounds amazing and what I have wanted for years. Can't wait to set it up tomorrow and have a play!

1 Like

I would be surprised if you can group series 1 (amp) and series 2 together.