Virtual 3-way switch


#1

1) Give a description of the problem
I have two separate GE switches controlling different lights in my kitchen. I would like to make them into a virtual 3-way switch.

2) What is the expected behavior?
Switch 1 turns on (or off) --> Switch 2 turns on (or off)
Switch 2 turns on (of off) --> Switch 1 turns on (or off

3) What is happening/not happening?
I’m looking for the best practice / most compact solution. This is easily achieved with 2 separate pistons, but I’m not sure how to do it in a single piston.

I was imagining doing something like:
on events from any of {switch 1} or {switch 2}:
if event was “turn on”:
turn on {switch 1}
turn on {switch 2}
else
turn off {switch 1}
turn off {switch 2}

Here’s my current approach:

It works, but feels clunky. Is there a more compact way?


#2
on events from switch 1 or switch 2
   with switch 1 and switch 2
      set switch to [$currentEventDevice : switch]
   end with
end on

#3

Nice, thanks. I just learned a thing!