Webcore - Seeking Guidance on Sonos Group Volume Control via Alexa

Hi forum members,

I hope you're all doing well! I've been working on creating a piston (or a group of pistons) to control the group volume of a Sonos system through Alexa. Currently, I'm utilizing Alexa, the recently released Sonos Advanced Control app with a device's [groupVolume], and a virtual dimmer switch.

The dimmer level is initially set when Sonos starts playing, using the value from the device's groupVolume. Subsequently, when I command, for instance, "Alexa, increase the Sonos Group Volume by 5," the dimmer level will be elevated by 5, and the updated value will be transmitted to the device's groupVolume. A precautionary check is in place to guarantee that they remain synchronized.

My goal is to ensure that both the Sonos device's groupVolume and the virtual dimmer switch are always in sync. However, I have a concern about the possibility of creating a circular reference in the process.

I've attached a screenshot of my attempts at writing the some pistons below. Could you please take a look and let me know if this is the correct approach? Additionally, if there's anything crucial I might be missing, I'd greatly appreciate your insights.

Thanks a bunch for your help!

Cheers
David