How does a delay work?

Does a delay just pause the execution of the next rule for that x amount of time?

For example

  1. Turn Off all the lights
  2. Store Speaker A volume property value in %volume%
  3. Set Speaker A volume to 100 (Delay by 2 seconds to give time for speaker to get this command)
  4. Text To Speech "The House Is Now In Away Mode" (Delay 5 seconds) This gives it time to get there and say what it needs to say before the next step returns the volume
  5. Set Volume of Speaker A to %volume%

Does rule 4 run then pauses for 5 seconds before executing rule 5? I am assuming it works this way but I just want to double check.

PS It would be really awesome if the Google Home sent a response back to the Hubitat that execution of the command was successful. That way you could add a wait condition in the Rule Machine to "Wait till previous command is complete" or force forward after X seconds if no answer was received!

Could you post your actual rule?

If there's a "delay 5 seconds" between steps 4 & 5, then step 5 will execute 5 seconds after step 4.

If step 4 is "delayed by 5 seconds" then step 5 will execute before step 4.

I don't have the rule it was just an example to ask a question which way does it work.

As stated, it depends on which way you set it up. :slight_smile: For the same explanation in different words (and a note about how cancellation works--also different between the two types of delays), you can also see this post:

1 Like

So in my example I want it to execute like i stated 1,2,3, Delay 2 sec, 4, delay 5 sec, 5

I would second @aaiyar's request for a screenshot, which would make the exact way you plan to set this up clear. What you said in your first post looks different to me than what you just said.

The difference is basically this:

Action One
Delay 0:05:00 
Action Two
Action Three

versus this:

Action One
Action Two --> delayed 0:05:00 
Action Three

...which, despite looking similar, have the above-noted differences.

Sure ill see if i can replicate when i get home to show

Ahh okay. Yes let me look at the rule when home, for some reason my VPN to home is down today either that my IP just changed and DYDNS is slow to update it. Ill let you know. Didn't know you could do both!!

Here is an extract from one of my rules.
When the actions are 'resolved', all four actions will put a delay into the scheduled jobs.
So in essence the actions execute at the time interval after the actions were resolved. (If that makes sense).
I could have out a 'Wait' in instead.
The wait, waits for the action above to execute then it moves on.
So I could have out in.
Wait 1 miniute turn on light 1.
Wait 5 seconds turn on light 2.
Wait 55 secs turn off light 2.
Wait 5 seconds turn off light 1.
To achieve the exact same thing.
I just went down the delay route. (Again, hope this makes sense. :slight_smile: )


1 Like

I think i am understanding... Ill have to play with mine when i get home to learn more but what you are saying is you could do this

Event. On button press

  1. Turn on lights 1, 2, 3
  2. Tun off lights 1, 2, 3 Delay 30 minutes

This would allow me to turn the lights on but after 30 minutes wold turn off correct?

That's wasn't clear to me from your original post. In any event, you want a delay between actions (@bertabcd1234's example #1) as opposed to a delayed action (example #2).

1 Like

Yes. That is correct.


Yeah I didn't even realize there was a difference is why haha I guess kind of why I asked the question because funny things were going on, now i know why because the way i stated it in the question is the way i have it which would cause weird behaviors. I want it to execute lineally with the pause between steps and now i get it!


There's also a third option--you could have used a (standalone) "Delay" action instead of a wait. :slight_smile: I guess the difference is mostly in how they can be cancelled: delays (standalone or on an action) can be cancelled with a "Cancel Delayed Actions" action if the "cancelable" flag is set. They can (less commonly...I don't think I've ever seen staff post an example like this) also be cancelled with a "Cancel Rule Timers" action from the same rule or another rule (which also cancels a bit more, including waits but also un-does periodic triggers tells you what else). Waits also start over when any trigger fires and the rule actions begin running again; delays, unless cancelled, stay pending.

1 Like

Cancel Rule Timers will also unschedule any periodic triggers the rule might have until you open the rule in the GUI and click "done". There is no programatic way to reschedule the periodic triggers.
That's why it's a very "drastic" way to handle delays. It's much better if you cancel the delay within the rule itself.

Okay so I am still confused.. I am looking at my rule i created and i want to insert a delay of 5 seconds before it continues to the next Action... How would I do this?

Follow @bertabcd1234's first example in this post, i.e. insert a "Delay 5 seconds" between the two Actions.

Also, if would be helpful if you posted your rule.

I'm still not sure what "rule you created," so a screenshot would be helpful. But I guess the same would apply to me, so here are my two examples from above. What we're talking about is this:


versus this:


If there is nothing after your delay or delayed action, they are equivalent, but as you can see, with additional actions, the behavior is different: a delay on an action continues to run the remaining actions. A "standalone" delay action pauses the rule there. If you added cancellations, there would be an additional difference stemming from that (only the cancelable delayed action would be cancelled in the first rule; everything after the cancelable delay in the second would be cancelled--but only if i set the "cancelable" flag and had a "Cancel Delayed Actions" action, which I do not).

1 Like

So between action 2 and 3 I want to wait for 5 seconds before the rest of the actions proceed

Insert a "Delay 0:05:00" (EDIT: or "Delay 0:00:05" if you wanted five seconds, as I mis-remembered...) as in my second example (in either post) between the desired actions. Also, I'm sure you're aware that, without triggers, these actions will never run unless you call them from another rule. (Also, depending on your speakers, some people like playTextAndRestore better than just playing the notification, which might stop anything you currently have going. Your luck may vary.)