[Nearing Release] Sonos Advanced Controller

Been trying to use your app. Unfortunately, I am unable to get it to create the players consistently. It will generally only create one at a time and then it won't recognize the players as having been created previously (won't allow me to select for grouping, etc.). Numerous "cannot connect" errors in log:

2024-05-25 11:19:37.307 AM[error] java.lang.NullPointerException: Cannot invoke method minus() on null object on line 201 (method localPlayerSelectionPage)

2024-05-25 11:19:32.161 AM[info]Sonos Advanced Controller: Could not connect to: 192.168.4.110:1443. If this is a Sonos player, please report an issue. Note that RIGHT channel speakers on a stereo pair, subwoofers, or rear channel speakers this is expected. Only LEFT channel in stereo pairs (or Arc/Beam in a center + rear setup) will respond.

2024-05-25 11:19:31.772 AM[info]Sonos Advanced Controller: Could not connect to: 192.168.4.42:1443. If this is a Sonos player, please report an issue. Note that RIGHT channel speakers on a stereo pair, subwoofers, or rear channel speakers this is expected. Only LEFT channel in stereo pairs (or Arc/Beam in a center + rear setup) will respond.

2024-05-25 11:19:28.742 AM[info]Sonos Advanced Controller: Could not connect to: 192.168.4.156:1443. If this is a Sonos player, please report an issue. Note that RIGHT channel speakers on a stereo pair, subwoofers, or rear channel speakers this is expected. Only LEFT channel in stereo pairs (or Arc/Beam in a center + rear setup) will respond.

Any suggestions? Thank you!

Went out and got a newer Sonos that supports S2. This allowed me to install SAC without error this time. Phew. My use-case is pretty basic: I'd like TTS messages, when they collide to queue up rather than interrupt each other.

But I'm struggling to get it working after a few hours of troubleshooting. Wondering if others have experience with the following:

  1. When I invoke playHighPriorityTTS, I hear the TTS message, but it doesn't queue up multiple TTS messages sent right after one another. It just interrupts itself.
  2. When I invoke the other TTS commands (speak, playText, playTextandRestore, playTextandResume), I hear nothing. The logs say that the message has been "enqueued". Does that mean it's queued up after some other track or text? If so, how do I "release" the message from the queue? This behavior seems to occur whether I'm playing a track on my Sonos or not.
  3. What does "Always use non-interrupting messages" under device preferences mean? I'm confused how to interrupt toggle on versus off. I've tried the above with the toggle on and with the toggle off, but it doesn't seem to change the behavior.

Appreciate any ideas. I'm stuck.

Love the app, thanks. Recently (perhaps upgrading to 2.3.9.135), I've observed something with volume control of individual players that are grouped together. If I adjust the volume of the player, it takes effect, but the Current State does not reflect a change or publish an event for the level/volume of the player. However, the player reflects the change in the groupVolume attribute. The same behavior occurs if I ungroup the players, as it creates a new group of 1 speaker, so the updates only change the groupVolume. I added logging, and Sonos returns only GroupRenderingControl (not RenderingControl). I had hoped it would be possible to reflect the changes in both, as I try to confirm the volume attribute after changing it.

Any help or ideas would be appreciated. Thanks!

setGroupVolume requires an additional cast as well. playerSetGroupVolume requires level as an Integer, or it throws an exception.

image

This happened to me as well. I believe what is happening is the players are not resubscribing to MRRC_EVENTS after the 3600 sec timeout. One workaround, which I first noted back in March, is to send an initialize() command to each speaker once every hour with a gap of around 10 minutes between the speakers to reduce the load on the hub. RM or webCoRE can be used to automate this until Daniel can provide a more permanent solution.

Hoping someone can help. I am trying to install this with HPM but keep getting the following error:

An error occurred while installing the package: Failed to install app https://raw.githubusercontent.com/DanielWinks/Hubitat-Public/main/Apps/SonosAdvancedApp.groovy. Please notify the package developer..

Thanks! (Negative points for my search skills.)

In the code, I may have found a "copy-paste without edit" that explains this. The resubscribeToMrRcEvents callback for the MRRC subscription (subscribeToMrRcEvents) is passing the MRAVT event and callback method to Sonos. So the initial subscription works, but the callback (100 seconds before the timer ends) is resubscribing MRAVT instead of MRRC.

I've recompiled with the MRRC constants. I'll know in 55 minutes if this fixes it. :slight_smile:

Edit: changing to the correct contants (MRRC_*) fixes the issue, and they automatically resubscribe to the MRRC events. Volume values update after the hour.

image

2 Likes

Ouch, I looked at that area of the code and missed that completely. It's insanely obvious now that you've pointed it out. :smile:

Let me know how it goes. I've made the changes myself and will be testing too.

1 Like

Hi @bthrock and/or @JDC,

I am experiencing the same issue and appreciate you identifying this and finding a solution. As I have limited knowledge of Hubitat code and @daniel.winks is currently not responding to posts, I would be grateful if you could help me implement the necessary changes when you are done testing.

Could you please clarify the following:

  • Specify what the changes are and what needs to be replaced.
  • In which modules should I make the changes (App Code, Drivers Code, Libraries Code, or Bundles)?
  • Are there specific line numbers where these changes should be made?
  • Do I need to compile the changes, and if so, how should I do that?
  • If possible, provide step-by-step instructions.

Thank you very much for your assistance.
David

David, the code referenced in @JDC's post (link) starts at line 1678 In the Sonos Advanced Player driver code. Simply modify the two lines with the yellow highlight so they read:

String evtSub = MRRC_EVENTS
String callback = MRRC_EVENTS_CALLBACK

Then click SAVE. It's a large driver so it can take a minute to compile, but once the circle stops spinning you're ready to go.

2 Likes

After the code change and compilation, you'll need to hit Initialize in the Sonos Advanced drivers for your devices. Then you should be all set.

2 Likes

Thank you @JDC and @bthrock. I will:

  1. Back up the current Sonos Advanced Player driver code and save it offline (cut and paste).
  2. Make the changes as per @bthrock's instructions.
  3. Save the driver and be patient with the time it takes to save.
  4. Initialize all Sonos devices using the Sonos Advanced drivers as per @JDC's instructions.
2 Likes

The backup isn't necessary, but it won't hurt anything. If you make an error, you can always do an HPM repair to restore the original code.

The initialize() step, which I should have mentioned (thanks @jdc), is important. I chose to reboot my hub instead, but only because I was doing some other testing at the time. Either way, it's been working as intended since then.

Hopefully, @daniel.winks will be able to rejoin us and make changes to the repository in the not-too-distant future.

So do I only change lines 1683 and 1684 or do I change
1683, 1684, 1702, 1703...

Just 1683 and 1684. It should look like this:

1 Like

Great, thank you @bthrock! I'm also looking forward to @daniel.winks' return. We were collaborating on debugging an issue I've been having via PM, and he even wrote some debug code for it. Additionally, I was assisting him with functional testing via PM since around the 5th release. However, I haven't heard from him in about two months.

1 Like

Does anybody know what this log message means: "messaged has been enqueued". I'm trying to figure out what enqueued means in this context?

Does anyone in the community know the cause of this error?

dev:567 2024-06-26 08:09:11.937 AM error java.lang.NullPointerException: Cannot invoke method playerModifyGroupMembers() on null object on line 123 (method on)

I've been using Sonos without any issues for months, but this error showed up today. I can no longer use the Sonos Group controller. With the developer unavailable, I was wondering if anyone else has suggestions.

Edit

I figured it out! For some reason, the Sonos Advanced Controller was missing one of my Sonos devices, which happened to be the Group Coordinator. After running the discovery process, it found the device, and I selected "Done." Grouping now works perfectly.

1 Like

Is there any way to turn off the errors for Roam devices that are switched off? (I typically only use mine when I go out on the back deck or other places in the yard that I want to use it, and Otherwise I keep it turned off so that I don’t ruin the battery with it sitting there at 100% on the charger all the time.) The errors in the logs every hour are annoying, and there’s no Way to adjust logging for the child device. Thanks!

Does tts work on your sonos roam?

Yes