Noobie question - control all lights in an area via Pleg


I’m new with Pleg and it’s an amazing platform.
I want to control all the lights in a define area in one virtual switch - turn on/off 5 lights in the Living Room.

For the practice I tried to work it out with two lights. I created virtual switch and made this pleg config:

LrLeftOff - Whenever the Left Lr is turned off
LrLeftOn - Whenever the Left Lr is turned on
LrOff1 - Whenever the Lr is turned off
LrOn1 - Whenever the Lr is turned on
LrRightOff - Whenever the Right Lv is turned off
LrRightOn - Whenever the Right Lv is turned on

LrOff - LrOff1 and (LrRightOn or LrLeftOn)
LrOn - LrOn1 and (LrRightOff and LrLeftOff)

LrOff - Immediate - 2 (turn off Right and Left)
LrOn - Immediate - 2 (turn on Right and Left)

In this position, when I turn the virtual switch on/off, the right and left lights are turning on/off (like they should), but I can’t keep the individual right or left light on when the Living room virtual switch is off.

I think that I need to config this action to be only when the virtual switch is manually changed, and not to be active at any time, because right now if its on “off” it turns the lights off whenever I try to turn one of them on. But I don’t know how to config it that way.

Thank you in advance,

Have you thought about something like below. It’s not using the Virtual Switch plugin but it has many more options for control.


You do not need two of every input Trigger!

Input Triggers:
LRVirtual when the Virtual Switch is On
LRLight1 when LR Light 1 is on

AnyOn LRLight1 or LRLight2 or LRLight3 or LRLight4 or LRLight5
AllOff !AnyOn
TurnAllOn AllOff and LRVirtual and (AllOff; LRVirtual)
TurnAllOff AnyOn and !LRVirtual and (AnyOn; !LRVirtual)

The addition of the sequence expression allows you to control the individual lights manually or with the Virtual Switch, preference is given to the individual switches.

Thank you very much for your answer, it helped me a-lot!
Your solution works great, except for when one light is on, and I turn on the virtual switch, it doesn’t turn all the lights on.

Thanks again for your amazing and useful pleg.

As I said … single lights have precedence.

You can remove the " AllOff and" from the TurnAllOn condition