RM Feature Request: Prevent rule from triggering if already running

I can only assume one is setting a schedule to resume the rule and one is scheduling the running of the command,,,, but I am likely wrong...

4 Likes

It does exactly what it says, but I can see how it can be confusing:

Option 1:
Delay 10 seconds = stop here for 10 seconds, then proceed to the next line

Option 2:
Do something after 10 seconds delay = Schedule something to be done in 10 seconds, then (after scheduling, not executing), proceed to the next line. The scheduled event will happen 10 seconds later (if it's not cancelled)

Having both options is really useful, but you have to be sure you're using the one that works for the rule you're trying to write

5 Likes

A delayed command is just that. A separate “thread” is created with the command and a trigger 10 seconds in the future.
It is no longer part of this rule at that point. However it can be cancelled, if so setup.

2 Likes

Makes sense now that you’ve explained it. :+1:

1 Like

Who'd of thunk it, maybe I was right.... :slight_smile:

2 Likes

Nah, can’t be true then.. :wink:

1 Like

All that is part of why “single threading” a rule is difficult.

3 Likes

In all honestly, RM is the first automation system I’ve come across that isn’t single threaded by default. I’ve used Reactor on Vera, HA’s built in automation, and HomeSeer.

I guess one way to think of it is it can be single threaded, if you want it to be... With the trade-off you need to know you are making that choice....

It seems like it’s very easy to end up with multi threaded RM rules and not realise it.

1 Like

It feels like a comical GIF is required for the action delay.... :wink:
But I wouldn't suggest searching for one....

1 Like

Most of the things that I want to work around actually have to do with triggers. I do not need to bail out of actions, I just need to stop the rule from starting in the first place. A good analogy is how motion sensors may have a timer to ignore retriggers in their hardware settings. What is the proper way to do that in Rule Machine?

1 Like

That what the Required Expression is for.

1 Like

This?

1 Like

No, you have to set up:

Until that is “true”. All triggers will be ignored.
Define your own expression, that’s just how I did it for my rule.

Thank you!

Edit to add: to the OP's point, while this trigger-defeater Required Expression is very useful I can also see value in adding shortcuts to the most common retrigger issues like "ignore this trigger if it went off within the last X minutes." I am sure that is possible to build in the Required Expression though I don't see how yet.

You can do that with conditional triggers.

3 Likes

But you'd still have to repeat that call at every exit point in your rule, so it would still be messy. Also you'd need a separate rule of which to run the actions for each rule you only wanted a singleton of, as each time it would be a different variable you'd want to set. This would therefore be worse than explicitly running the variable setting in the original rule.

@bobbyD Does the “run actions” command execute the “actions” like a subroutine and return or does the command just “launch” the specified rule and continue on in parallel?

It runs in the actions from that rule in parallel to the rule that called those actions.

The starting rule keeps running, unless you introduce a wait after calling those actions with some sort of logic to resume after the called actions finish.

2 Likes