There must be an elegant way to do this but I cannot think what it is: suggestions please!
I have a bunch of virtual devices set up for 'radios' around my house. The radio source is VLC running on my server and tuned to an internet radio station. The virtual device on/off action groups take care of connecting / disconnecting speakers using AirFoil etc. to make the individual 'radios' come on and off. Because I have one radio source, I have a counter variable which is incremented and decremented by the virtual device action groups and when it gets to 0, a trigger then stops VLC (and other trigger starts VLC streaming again when the counter becomes >0). So far so good.
Sometimes for various reasons an off command will be sent to these virtual devices when they're already off. In these cases, the counter gets decremented when it shouldn't.
I can think of lots of really messy ways to resolve this, but they're all really ugly. I really want to put the solution in the virtual device action groups rather than all the places that send commands to them, for ease of maintenance. The best I've come up with is to add a script for each virtual device 'off' action group and have the script check whether it's on first. But I don't want to write a bunch of scripts if I don't have to, as for simple things like this it's easier to maintain without scripts in my view. If I could add conditions to an action group, I'd be sorted but of course that's not possible.
Any suggestions please? Ideally avoiding scripts.
Thanks!