Adjust master swtich to reflect status of slaves

I’m using “Dim with Me” with a virtual switch to control a bunch of lights. I would like to set the state of the master to reflect the individual bulbs in the following way. If all slaves are off, the master if off. If any slave is turned on, the master is turned on WITHOUT turning on all the other devices. I have the “all off” working. I was hoping that I would simply be able to unsubscribe the master “on” event, turn on the master and then subscriber to the master on event again.
As soon as I unsubscribe from the master event, my master.on() stops working.
Not sure if I’m doing something wrong or this simply won’t work without messing with the device type.
Any help is greatly appreciated.

Have a look at rule machine, it should be able to do this.