Only Trigger Rule Once

Perhaps I should know better by now,,, But it feels like an option for a Rule Machine rule to only ever have one instance triggered at any one time would be useful, if only more easy to configure than it is currently. I don't doubt that I have missed something obvious that would achieve this, or that their may be complications in implementing this,,,

You might be aware that this is what a rule’s Private Boolean is good for.

Did you mean there should be an additional method available to restrict the triggering of a rule only if a previous instance has finished its actions?

1 Like

Yes and Yes... :slight_smile:

Exactly my point about not being on my game in terms of existing features... But also... yes, it would be nice if this option was a little more obvious / explicit in choosing to enforce this in a rule...

1 Like

I think you're on to something. A simple toggle for 'only allow single instance of rule' or 'prevent re-trigger until rule has completed' would be much more intuitive.

Behind the scenes it could implement a 'set Private Boolean false' at the top of the rule and a 'set Private Boolean true' at the end, with a required expression of 'private Boolean is true, with all of those mechanics hidden from the user and only the 'single instance' toggle visible.

4 Likes

That would be a nice win for ease-of-use, especially for folks new to rule logic.

If it happens, I'd vote for language along the lines of your 'prevent re-trigger until rule has completed' suggestion, since terms like 'only allow single instance of rule' or 'only trigger rule once' could get confused with stuff like trying to run a rule just once a day etc.

2 Likes

Seems to me that this is almost impossible in a system that is event driven, as Hubitat is, and in which Rules schedule items for future execution. While you might have a sense of when “a rule has completed”, that’s a really difficult concept in the general case unless every rule is required to do an explicit “EXIT RULE” when it has “completed”.

1 Like

I get what you are saying, but at least something that can achieve the same outcome as we are forced into would be nice....

What I'm proposing is a shortcut to do what we can already do manually... (set required condition = private boolean true, set private boolean false as the first action, set private boolean true as the last action) without exposing those steps to the end-user. It is already possible.

You wouldn't want the user to set the private boolean elsewhere in the rule and potentially mess things up, so it might be best to use some new hidden variable and not the existing PB.

You make a good point about actions scheduled for future execution. There is a difference between 'delay X seconds' and 'do action Y, delayed X seconds' as the latter schedules the action and continues through the rule actions, and the former waits at that point and doesn't do the next action until the delay is over. It would be good if any documentation for the feature mentioned that future actions could still be scheduled when the rule actions complete.

This wouldn't create a new capability, just an easier way to do something with fewer steps. I don't know if that makes it worth the development time for Hubitat, since they may put more priority on adding features that provide new capabilities.

1 Like

Actually not true, in v2.2.9 @gopher.ny added a "singleThreaded" setting for drivers and apps that prevents multiple executions of that code.

I use it quite a bit in my custom drivers and apps. But this said I did find it doesn't work with child apps of a parent. So not sure this would work in its current version with Rule Machine.

I would prefer that the singleThreaded feature be leveraged vs private boolean.

I do support @sburke781's feature request here because I had a rule in place that kept logging multiple execution errors in the log and I had to write my own custom app instead to get aroung that.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.