Keep 2 light switches at sync

How to keep 2 light switches at sync without having a "disco" when they will start triggering each other on and off in loop?

It works well when I press light switch once with this rules:


But if I press switch 2 times in a row, the change will start propagating both ways in a endless loop

I have 2 light switches, the one with world virtual is not connected to any actual light, the one without it is the one what actually is connected to bulb.
I made zigbee group called "living room lights" out of both of them.
I want to keep light state at sync on both of them (right indicator is light off or on) and be able to turn off/on light using any of them

Look at the built in mirror app, does that do what you want?

5 Likes

I found the Switch Bindings app by @jwetzel1492 to work pretty well for this with my use cases.

4 Likes

hi,
there is a built in app that is called mirror and this will make other items mirror the status of a master, this works pretty well without the use of rule machine

if you want to use rule machine you need to change your rule to when the virtual switch is pressed it toggles all devices stated, so you dont have to have an on and off part of the rule, i hope that helps

I tried using toggle, but result was the same.
When I will press switch, it takes 1s for toggle to take effect on another switch. That tiggers another toggle from second switch to first one. And loop is going

I am trying the apps mentioned in thread now :slight_smile:

Switch Bindings works perfectly :slight_smile:

2 Likes

have you by any chance got the "auto off" enabled on the virtual item ? or on the lights in question, the only reason i ask is that youre trying to achieve something that pretty basic so there must be something enabled somewhere (i do this all the time ) i think i do it to torture myself

There is no virtual item technically, I named them wrong. I should call one master and one slave or something.

I have 2 physical switches, but only one of them is connected to actual light. The one what is not connected I called "virtual", but it is not really "virtual" switch, it is real switch but with no light connected to it

gotcha, if either of those have the auto off enabled in the device youll end up full disco

No, no auto off. As said it worked fine but only as long I press one of switches once. If I turned light on and instantly off, then disco started
Auto off would turn light off, I want to keep both of switches at sync

so are you saying if you turn it on the immediately off it discos? maybe your going faster than the rule would allow, i know when using the mirror function you dont have the disco drama, it might be worth a quick try, it ll take you about 7 mins to download the app, its one of the included ones on the hub, youd just need to click disable on your other rules,id be interested to know why youre getting the disco effect though, it may be worth turning logging on and having a look at the log after youve made it go disco

Switch-Bindings works perfectly, I am happy with it, but also I am curious how to make it wil rule machine if possible so I can do some tests :slight_smile:

so are you saying if you turn it on the immediately off it discos?

Yes, exactly, they trigger each other and when second switch will turn on as the result of first one turned on by me, it sends trigger back to my switch (the one I physically used) to turn it on (I already turned it off by clicking second time). Then trigger from my switch to turn off second one, goes to second switch and turns it off. What generates trigger to turn my off, but previous trigger from this switch already turned my switch on and generated trigger to second switch to turn it on.

I will re enable these rules and try to produce some logs

Disco:

Out of:

Yup, the infinite loops are something I had to deal with in writing the code for Switch Bindings. I think it would be challenging to handle in Rule Machine, but was very possible in Groovy code.

3 Likes

Is it possible to have Sonos's state (playing/stopped) as a "switch"? I need to link a virtual switch to the current state but end up in a loop using rule machine.