Prevent Same Rule from running more than once at a time

I’m using a rule to auto close my driveway gate, but that really doesn’t matter.

There are some scenarios in my situation where I can get the system a bit confused as it can have the same rule running more than once at a time.

Is there a way to set a rule so that if the rule start trigger is initiated, it will stop all other cases of this rule that may be currently running to prevent potential conflicts with itself?

I usually do this by creating a variable that gets set to “on” at the start of the rule.
It only runs if the variable is “off”. At the end of the rule I turn it back “off” so it can run the next time.

You can also reset the variable after a time period.

2 Likes

That is quite logical, however, I’m trying to do it just a little bit differently.

lets say my trigger starts at 12:00. The rule starts iteration “A”.
Lets say at 12:01 my trigger event happens again. If this is the case, I want the rule to no longer finish Iteration “A”, and instead start the rule all over again from the beginning (Iteration B).

In your example, B wouldn’t run, but A would finish running. I want the opposite. I want A to stop running and run B from the beginning.

You can still reach that with variables, it just gets a bit more complicated.

Could you explain the full use of your rule, it would make it easier to think about it and not get into “yes, but then I need…”

Sure…I"m going to simplify it just a bit as I have some other elements to my rule that have nothing to do with this.

I have it on a driveway gate (same concept as garage door). My clickers are connected to a smart relay which in turn sends the “push button” signal to the gate.

The Smart Relay is my trigger.

When the rule is triggered, it waits for 1 minute. After that time, the rule looks at my “Gate open” sensor to see if the gate is open. If it is open, sends the “push button” signal to the relay again to close the gate.

When it does close the gate, the rule is triggered again, but this time after 60 seconds it sees the gate is closed so ends the rule right there.

Where it gets tricky…there are times where I walk through the gate to go to my car. From the time I open the gate, get in my car and drive up to the gate, it maybe takes 30-40 seconds. Because my gate is old and doesn’t have any sensors on it, the gate will close on a vehicle and damage it pretty bad.

So, rather than wait the 30-40 seconds for the gate to close on it’s own, and then I re-open it, I would like to press the clicker button to close the gate right then and immediately press it again to reopen it, starting my 60 second cycle all over again.

HOWEVER, with how it currently runs, if I do this, my very first iteration of the rule is still running, and if timing is just right, the system can automatically close my gate while I’m inside it’s path.

Clear as mud?