Gate rule to close on a delay after trigger between times

The gate is working fine in the dashboard and have a Basic Rule that
When Time of Day is 60 minutes after sunset ...
Turn on West Gate
Wait until Time of Day is sunrise, then ...
Turn on West Gate
Having trouble with this RM.

The goal is to have a closed gate open and close (delay 4 min) between sunrise and sunset.

Well I'm assuming something is causing the ON but the actions are another ON not an OFF. So if an OFF closes the gate there is no off command there.

I'm using a Zooz ZEN 16 to trigger the gate, momentary switch. That explains the on, on triggers.

Given your explanation above, that looks like it should work -- mostly. There may be problems if the rule re-enters before that 4-minute delay is up because nothing cancels that. I normally suggest using "Wait for event: elapsed time" instead of "Delay" to make that easier, but you can also mark the delay as "cancelable?" and add a "Cancel Delayed Actions" action to the beginning of the rule.

I'm not saying that explains your problem, but it might be one possible outcome in your case. If you have additional problems, I would:

  • enable all logging on the rule and see what Logs say if it doesn't work as you expect, which should tell you what is happening when (ideally, filter to your rule when viewing)
  • make sure you do not hit Done or Update Rule while the wait/delay is in progress, as these steps "re-initialize" the rule and will cancel things like that (just viewing the rule is fine)

Isn't the rule just setting up a loop?
On triggers the rule, delay 4 minutes, then On
which triggers the rule, delay 4 minutes, then On
which triggers the rule...

Ya I’m trying to figure the double on as well.

There is a contact sensor in the required expression, which I assumed is supposed to correspond with this same device. If that is correct, then it should prevent this. If not, or if that device doesn't support accurately for some reason, then it certainly could be an issue.

I didn't make that link but that does make sense.

Not clear what you are trying to do..seems like you are over complicating it.

Why not just write two.rules.

  1. Open at sunrise and
  2. close at sunset.

Or is it when someone comes to the gate it opens and closes 4 minutes later?

If so i would do

Rule 1:
Required expression - time between x and y
Trigger: sensor trip
Action: Open gate
Close gate delay 4 minutes.

Rule 2:
Close at sunset or at the end of your time period.

Goal is when someone comes to the gate it opens and closes 4 minutes later.
Updated the rule to Wait for event instead of delay.



Gate remains open?

You want to wait for an elapsed time, not this device event--replacing the delay, keeping the rest as-is.

New to RM. Add New Variable or Action?

Confirmed. Loop every 4 min.

It is an action, and you basically already found it, it seems--just chose the wrong options and put it in the wrong spot.

I don't see a need for variables in this rule.

Agree, over complicating, that's why I'm here.
Two rules are the solution. The 1st one is working fine overnight. It's the day time rule where the gate is closed to open and have it close after someone enters.
The overnight rule doesn't run if the gate is already closed.

Added the Wait for event, elapsed time. In the right spot? Stalled at Wait?


That looks correct, and there's no reason it should have stalled at the wait. I'm assuming you waited at least 4 minutes? Also, you didn't open the rule and hit Done or Update Rule or do anything else that might have cancelled a timer?

Also, thinking of this more: does the gate always close automatically or might you manually close it before the 4 minutes are up? If the latter is the case, you'll need to add something else to make sure it doesn't actually open via that "on" command when it's already closed (but that would not be causing this particular issue).

It could have stalled if the rule was reentered.
You may need a cancelable or a delay wihich i.dont think would work the same?

Here is the log. The gate is closed while the last entry on the log is 'Action: Wait for event: --> elapsed time: 0:04:00'
Also looks like the rule in in a loop?
No manual closing, might think about disabling until the time is up.

Confirmed, the gate is opening and closing every 4 min.