Hello!
Despite the title, my ultimate goal is to connect a sonoff switch set on Home Assistant with virtual switch on Samsung Smartthings. My idea is following (if you have idea to do it better, I;d love to hear!). To do this, I’ve managed to:
Setup sonoff as mqtt switch1 on home assistant.
Setup smartthings virtual switch as mqtt switch2 on home assistant with mqtt bridge.
The only thing left is to link switch1 with switch2, so that always when switch1 is turned on, then switch2 is turned on. The other way around as well. My question - how to do it?
Well actually there is a problem in this solution. When I quickly turn on and off one light (within half a second), then two light go into feedback loop, when when one changes before receiving info, that the other changed to the opposite one. That causes lights to flash on and off repeatedly. Can this be handled in any way? IS there a way to detect if light changed because of the automation?
I got shot down for suggesting this before, but isn’t this a perfect application for Rules?
The following rule is on my deck light (a Sonoff Basic), and when the deck light is on, so is the garden light.
rule1 on Power1#state=1 do publish cmnd/Garden/POWER on endon on Power1#state=0 do publish cmnd/Garden/POWER off endon
rule1 1
Sometimes it just happens, when you f.e. walk into the room, turn on the light with a switch but then realise you want to have the other light on instead. So you turn on the light and then off almost immediately.
Understood - I tried to do that through the web interface and it was basically impossible to replicate.
Tried with the switch/button on the HW itself (was a little easier, still, the timing had to be exactly right) and I got to the same point as you did - it was a nice alternate blinking effect for my XMas lights, though
Only way to get rid of that I can think of would be to put a stats sensor on one of the switches and if it counts, e.g. 4 changes in 5 seconds, it turns the syncing automation off for 3 seconds and then back on again (or stops it for a very short time in another way).
This solution is not perfect for me. I use it for a long time and am not sure anymore if it ever was like this, but when I switch the light, it will not come back to it’s previous brightness. I have it linked to a wall switch.
It doesn’t matter if I control using philips Hue, the light, or the switch, it will always start at the lowest brightness whenever this automation is active.
Anyone knows how to solve?
Alright,
Now it works… I have removed the transition: 0 and it seems to be okay. Adding delay does not work for me at all.
Thank you for sharing. Your solution works well if turn on/off the light of switch slowly. I just tried to turn on or off the touch switch quickly, both of the switches will repeat to be On & Off forever.
I’m looking at doing this exact thing (linking the state of two switches together). My electrician wired two separate light circuits when I’d really rather just have one… so it should be easy enough to have two smart switches in sync so either switch turns on both switches, and either switch turns off both switches.
Unfortunately, I am having trouble with an infinite loop as was mentioned above… if I accidentally hit both switches at the same time and turn one on and one off then they just keep flipping each other back and forth… did anyone find a way to prevent this? I will try the delay mentioned above but it seems dubious that simply adding a delay would prevent the infinite looping… it seems like it would just cause them to turn on and off less quickly. What’s the logic behind adding the delay? Is there a more foolproof way to do it?