Do actions run only after previous completed?

Hi all
Do the Rule Machine actions run sequentially, even if there is a delay (e.g. if there is a 5s delay on one action, the next action will still only run once that delayed action is complete)? I'm having actions run out of sequence and don't know if it's that or the fact that my HUE bridge isn't processing the actions correctly.
Thanks
Alan

This is a question I too wanted to understand. I guess we could experiment with a simple routine that features a delay and time it with a stopwatch, but if someone here can tell us that the delay must be completed before the next command starts, that would be great! Thanks!

If you have a group of actions, they will all be executed essentially simultaneously, even if some of those actions have delays.

These all execute at once, with the alarm turning off 5s after the two lights come on.

turn on light
turn off alarm delay 5s
turn on chandelier 

However, if one of your actions is specifically a "Delay", actions following that statement will not be executed until that delay completes.

The first action executes, then everything else waits for the delay to complete

turn on light
delay 5s
turn off alarm 
turn on chandelier
2 Likes

In addition to what @ogiewon said, you can debug this issue by turning on logging for the rule in question (enable Events, Triggers, Action).

The log from when the rule runs will tell you the temporal sequence of events and actions. And you'll learn if something specific is awry.

1 Like

I have been over looking that settings for weeks trying to figure out a rule error. This should help a ton, thanks!

1 Like

That is not what I thought would happen. I thought it would process all actions one after the other fully. Thanks for the education.

2 Likes

Hereā€™s the official documentation

https://docs.hubitat.com/index.php?title=Rule-4.0

And the original RM 4 thread which explains a lot as well...

2 Likes

The short answer is no. Rules are started sequentially. So they progress line by line, but if an action takes longer to complete than the next action in your rule they can get executed out of order. A delay on an action only effects that one action. So with a rule with two actions; if action one turns on a light with a delay of 5s and the second action is a chime making a ding sound with no delay. The chime will ding immediately and the light will come on 5s later.
I have found this to mostly only be a problem when using capture and restore of light states. Most actions happen so fast that they will execute in order. Your logs are your friends.

@ogiewon @aaiyar, RM4 is a wonderful step forward, but it is still really a challenge to wrap one's head around for reason like this for some of my rules that work like this. I honestly think that no one should have to go through logs to test if their rules work. That's not great UX. I believe that those logs should not be the main test for the rules we create. Some of my rules are hours long and I hope I'm not expected to perfectly navigate the drop downs the first time to ensure things like ensuring that certain devices are turned off and then back on in an approripate sequence during "peak time" due to utility company "time of use" scheduling (thanks for Day of Week and Periodic Scheduling btw). That could be a disaster!

I feel that with some simple additions to the UX would go a long way. For instance, it would be great to generate a simple flow chart order of expected operations. You have some great ways of displaying that with "if-then-else" style rules. Would love to see that translated to these kinds too (if you have, I honestly haven't seen it yet and would love guidance).

Using your example, If i write this:

turn on light
turn off alarm delay 5s
turn on chandelier
turn off light delay 3s

the user should see this as a Rule "Chain of events" Output:

turn on light
turn on chandelier
After 3s, turn off light
After 5s, turn off alarm
(a flow chart would be awesome as things get more complicated with cancelling and conditionals, but indents work too)

Especially what i would assume- and want- to happen is this, in sequence:

turn on light
After 5s turn off alarm
turn on chandelier
After 3s turn off light

This is one of those things you may want to help users along with, esp as some of us have complicated rules. No one wants to spend hours debugging logs when it could have been displayed to them up front :).

1 Like

That would be great. One of the things that holds hubitat back from having a much better reputation is that it is seen as overly complicated. To have the power it does, it needs to be, so as to give you the full control. But as you mentioned, some additions like that would make it a lot easier for people to visualise what will happen.

1 Like

@yot, just want to make sure you're aware that @aaiyar and I do not work for Hubitat. We're just community members and users of the Hubitat hub. :slight_smile:

1 Like

Haha, I figured @ogiewon . :slight_smile: But you're our awesome "Ambasadors" who are aware of our converation and needs and I hope that you could both advocate for us to those with "Staff" by their names :wink:

BTW, been using some of your ST_Anywhere code on hubitat for a while now. Just wanted to say a big THANK YOU!! @ogiewon. I do owe you a :beer: .

1 Like

OK... I'll tag @bravenel for you. :wink: Hope that helps!

1 Like