Stop a Switch from Turning Off More than Once

Hi,

I've had a look on the forum and I can't seem to find exactly what I'm looking for. Hopefully someone on here can help.

I have 5 light switches. They control different physical circuits but are all part of an open plan living area. I've created a rule that turns on all switches when a single switch is pressed. So no matter where you are in the room you can control all the lights.

The problem is that these switches are touch sensitive and if someone presses the switch too long, or people aren't sure how to use the switch and press it twice, the off function is activated. With there being so many switches that means there can be "on" and "off" commands circulating at the same time leading to them getting stuck in an on / off loop until I pause either the on or off rule in the app. It also ends up removing the devices from the network because their hard reset involves pressing the switch times. Without some kind of pause or more clever logic in the rule, the infinate loop always ends up being triggered.

To be clear I've made one rule for "on" and one for "off" rather than a "toggle" command to try and increase reliability. I also tried setting a private variable justpressed with a 5 second count down (when on is pressed, the off rule shouldn't be able to to be fired for 5 seconds). But neither seem particularly reliable.

I'm wondering if anyone has any advice on how to increase the reliability of the rule, or alternative ways of making this work.

Trigger:

Switch - Hall Down 1, Switch - Kitchen Hall 1, Switch - Kitchen Rear 1, Switch - Kitchen Boot 1(off, on, off, on) any turns on

Action:

IF (Variable just-pressed(false) = false(T) [TRUE]) THEN
On: Switch - Hall Down 1, Switch - Kitchen Hall 1, Light - Kitchen Strip, Switch - Kitchen Rear 1, Switch - Kitchen Boot 1
Set just-pressed to true
END-IF
Delay 0:00:05
Set just-pressed to false

Thanks!

Your method of using a variable should work. Make the variable being false as a required expression for the rule(predicate). Then set it true on the very first line of your actions. The rule then will not trigger again until it is set false.

You can remove the IF and everything else can remain as is I think. That might do it.

Thanks, I was hoping there was some magic I was missing.

I've moved the rule over to rule machine 5 (was previously in legacy 4), and I've deleted the old rule. I've implemented the predicate rule. I also thought it might bolster reliability if I put both the "on" and "off" conditions under the same rule. So I now have:

Trigger:
Switch - Hall Down 1, Switch - Kitchen Hall 1, Switch - Kitchen Utility 1, Switch - Kitchen Rear 1(on, on, on, on) any turns changed

Set just-pressed to true
IF (Variable on(true) = false(F) [FALSE]) THEN
On: Group - Kitchen Strip Lights, Switch - Hall Down 1, Switch - Kitchen Hall 1, Switch - Kitchen Utility 1, Switch - Kitchen Rear 1
Set on to true
ELSE
Off: Group - Kitchen Strip Lights, Switch - Hall Main 1, Switch - Kitchen Hall 1, Switch - Kitchen Utility 1, Switch - Kitchen Rear 1
Set on to false
END-IF
Set just-pressed to false --> delayed: 0:00:10

The lights now get caught in an infinite loop instantly. When I pause the rule the lights then settle down on the last switch state. I guess I just don't get it. With the predicate condition and trigger in place, I don't understand how this doesn't work. Do you have any thoughts on my updated code?

I was wondering if a variable is specific to an instance of a rule, and maybe I need to put the variable somewhere else / make it global somehow?