Subscribe to Sonos volume level event

I’m trying to subscribe to the volume level event of a Sonos zone player. The purpose is to keep the volume below a certain level. I’ve tried using the code below, but nothing is ever sent to the levelHandler.

def subscribeToEvents() {
subscribe(sonosZone, “level”, levelHandler)
}

def levelHandler(evt) {
log.debug “$evt.value”
}

Where am I going wrong? Is this an event that can’t be captured?

I stuck with it and found that if I add [filterEvents: false], it works as expected. I’m going to go read the documentation to see if I can figure out why that is, but if someone knows and would like to educate me, I’d appreciate it.

I’m having issues where sonos is no longer reverting volume back to the value it was at before an alert played. Also it is not resuming the playlist like it used to. is this what you are trying to fix as well?

This is how it has always worked. You as well as others have pointed out the folly in the design. Hopefully SmartThings “official” release will address this when it comes out of the labs.

I had issues when I first set it up, but then it worked perfectly for a long time. Resuming pandora tracks and reverting to previous volume. Recently that changed.

I’ve seen the same behavior as you, but that’s not what I’m trying to address. What I’m trying to do is limit the maximum volume for a zone. I have a connect amp that’s powering two speakers outside and I’d like to avoid making the neighbors too angry with them.

I have the app working as I want it to when installed in the IDE, I can turn up the volume using the button on the device or the Sonos controller on any other device and if it goes beyond the chosen level, ST will turn it back down within a second.

However, it doesn’t work when installed through the android app…strange.