Timer restart?

I have a simple rule that says,"if either one of my garage doors is open, closer it after 30 min". This works fine, the problem is that it 28 min, for example, has gone by and the door is closed, if someone reopens before the 30th minute, it immediately closes. How do I or can I restart the timer?

Make your delay cancelable and add a cancel delayed action at the very beginning of your rule.

You may also want a separate rule for each garage door opener if you don't want one changing to effect the timing of the others auto close.

1 Like

@Terk is correct having them separated probably would be better.

Once you get one working you can just clone it and change the opener.

This works! It's also what you'll see in most example rules for similar "cancelable" automations (e.g., lights with motion where you want the lights to stay on if motion resumes).

Something else you can consider is a rule like this:

Trigger: Garage door opened

Actions to run:

Wait for event: elapsed time --> 0:30:00
Close: Garage Door

or, perhaps,

Wait for event: elapsed time --> 0:30:00
IF (Garage Door is open) THEN
  Close: Garage Door

(The second way probably isn't necessary, since sending close() to a device that is already closed should have no effect, but if you're really concerned about it, you can check first.)

Either of these has the same outcome as the above, while being perhaps a tad easier to write, triggering/waking less often (shouldn't be a concern at all for a rule like this, but slightly more efficient, and no need to check the value since it won't trigger in other cases), and eliminates the need to manually cancel since "Wait" actions are automatically cancelled on re-trigger.

Just something else to consider! :slight_smile: (And I also agree that separate rules would probably give you the actual outcome you want over combining them.)

That's a great idea to separate them, thanks I'll do that. Pardon my ignorance here but I guess I'm not clear. Here's what i've done so far. Making it cancelable does what exactly? Just turning on Cancelable (like in the screenshot) isn't enough right? what else would I need to do and what's the logic to say, "start over" when they door is opened or closed. just a bit confused..

That is correct, Just make it cancelable.

Then add the line cancel delayed actions as the very first line of your rule.

What it does is if the rule is triggered again, if the door closes for instance, it cancels the delay and stops processing actions after that point.

I personally have started using the wait for events as given in @bertabcd1234's examples. That is a little more efficient. all Waits are automatically canceled once the rule is triggered, no need to add an additional line to explicitly cancel it..

1 Like

OHHHHH, okay. I'm a dork. I see what you mean. Turning on cancelable says this can be canceled, BUT you still have to perform the action to do that. I've never done that - so awesome, what does it actually look like? Does it go with the IF/THEN or before it? I would think before. Also I clicked the link you sent but there's a bunch of stuff on there, should I just search for timers or cancelable actions?

You only need it to be cancelled if the door is open, so you could put it inside the IF THEN. That being said, even before (first action in your rule) would be fine since in the other case there either wouldn't be a delay scheduled (so it would do nothing) or the door would already be closed (so you don't need to cancel it and, again, sending a close() to a closed door shouldn't actually do anything). You can see lots of examples in the Rule docs, which I'd strongly recommend reading if you use Rule Machine (these are technically a bit outdated, written for Rule 4.x and assuming some Rule 3.x knowledge, but Rule 5.0 isn't that drastic of a change so most still applies): [Released] Rule 4.0. Note the examples of cancelable delays towards the beginning of the doc.

Or...you could use the "Wait" actions we've suggested above instead. :slight_smile: Note that these generally work best with a specific trigger, not a "changed" trigger, due to how their automatic cancellation works--but it makes things easier since you don't need to do it on your own. But either (wait or delay) should work if you put the right pieces together!

OK so i did this above for delayed, i found it. So since I have changed in my trigger, when the door OPENS or CLOSES the cancel action hits and will not shut the door until the 30 min is UP, am I seeing that correctly?

But you've intrigued me with the WAIT. If i add a WAIT, I'm waiting on what and for how long? I'll read up on the rules. I setup this up a long time ago and have a pretty solid system running and I haven't been keeping up with this and the new changes so that's on me to learn for sure. I only have about 56 rules and 35 simple automations so I'm a bit of a pup with these RULES, lol

See below for a cancel delay action

You're waiting on whatever you choose, either indefinitely or with a timeout you can also choose. :smiley: The specific wait I suggested was:

Wait for event: elapsed time --> 0:30:00

So, in this case, you are just waiting for 30 minutes to pass. It's similar to a delay of 30 minutes, aside from the automatic cancellation thing. (But more generally, you can also wait for specific events to happen or specific conditions to become true, either indefinitely or with a timeout; the above is a specific type of wait that just waits for a certain amount of time and was recently made more discoverable in the UI, perhaps because it's useful for things like this.)

But yes, your description of how you're using "Cancel Delayed Actions" is correct, and that rule should also work--so no need to change if you don't want to try out the "other" method! I just like suggesting it since I think it's often overlooked. :slight_smile:

I thank you for it. Pushing me to look at WAITs can pay dividends for other rules. I have a few rules running with time delays and this is going to solve way more problems I've overlooked than these garage doors so thanks so much to you and @terminal3 & @Terk

1 Like

Download the Hubitat app