Use Sonos Connect state to control smart switch (with an integrated delay)

I’d like to put my stereo amplifier and powered subwoofer on a Z-wave Smart Energy Switch. When my Sonos Connect is playing, I’d like to turn the switch on. When the Sonos Connect has been stopped for 15 minutes, I’d like to turn the switch off. (The delay is because the amplifier itself resets to ‘off’ after a power loss.)

Any thoughts on how I might accomplish this? Is there a way to add a new trigger (with optional delay) to the Hello Home actions?

Create a virtual on/off switch. Have it turn on/off when your Sonos is playing. Then create a smartapp that subscribes to the virtual on/off switch and sends it to handler. If off, use runIn (15, [name of routine turning z-wave switch off]) and if on, use unsubscribe.