Button toggle change and resume

Hello All,

I'm trying to figure out how to create a rule for a button that will turn on all light switches, and set all dimmers to 100% with the first push, and resume with another push. Any ideas?

I bought a bunch of those Sonoff buttons from China and for $8 they work great. The batteries were mostly dead when I got'em, but those were cheap enough to replace. Anyway I wanted to put a button outside under an awning that when you have a bunch of stuff to carry in, or out, you press it and the house lights up like a prison break. Hit it again and everything returns to the state that it was prior to hitting the button. Thanks in advance!

Here is one possible way to do this, with the trigger being the button 1 press.

You will want to replace “VirtualSwitch, Virtual RGBW Light” with all the devices you want to trigger with the button.

Let me know if you have questions! (And if it works!)

Ah, interesting rule. It has an intentional race condition. It will trigger the rule with the second button press, which will also fulfill the Wait for event. A new trigger cancel's a pending wait. But, the rule should work 99% of the time because the pending wait will come to life before the simultaneous trigger can cancel it. However, this is non-deterministic, and there can be no guarantee the threads work as expected.

Ha, I have a similar rule for a completely different application, and use the exact same overloading of a button event. I think it works most of the time, but its failure would not be super obvious.

Strictly speaking you could dispense with the variable protector by simply introducing a 1 second delay (or less) after the Wait. Both halves run at the same time, but the lights are already 100% so setting them to 100% again doesn't actually do anything. Then, 1 second later it restores them. But, the use of the protector variable is clever...

2 Likes

Would an else not be better than a wait
If app running false
Capture
100%
App running true
Else
Restore
App running false
End if

2 Likes