Rule Machine Instance Counter

@bravenel is there any way to see how many instances of a rule are running? Clearly the goal is for there to be only one, however it would be handy to see some kind of count to let me know there is an error in my approach.

Thanks
Chris

I suppose you could increment a variable every time it runs. But there is no method aside from that to do it.

1 Like

I guess the first line of each rule could increment a hub variable, and the last line could decrement it - and another rule to watch the variable events and store the highest value reached

1 Like

You can also use a Private Boolean to force every rule to be single-threaded.

Execute the rule only if the PB is true. Set it to false in the first line of the Rule, and back to true at the end.

4 Likes

Doh! That's the best one of all :smiley:

1 Like

this is how i would limit my rules to one instance. use a PB to determine if the rule triggers or not

1 Like

To check how many instances run I send a Pushover notification. This for debugging a rule that should only run once a day (but fires 2 or 3 times quickly even with the private Boolean), obviously not ideal for a rule that will run frequently.

You may need to debounce whatever triggers it. See this app in the public repo for an example of how that is done:

Thanks! I just started debugging the rule, this will save me a lot time. And public repo, I had no idea it existed, awesome.

I have been trying to us the PB approach but I am clearly doing something wrong, I am used to PLCs and the concept of a scan but I am not sure how Hubitat executes rules. When the predicate rule is false does this rule finish executing or does it work like and exit rule command and stops before finishing the entire scricpt?

Here is a second concept I have tried using two rules, one for turning something on and one for turning something off. Still gets hung up now and again, no idea why.

On:

Off:

Use your first example (with the Predicate). But set the PB to be true right after the END-IF. Also, you might consider updating your platform version. There have been multiple changes/enhancements to Rule Machine.

If the Predicate (now called Required Expression) is False, then the Rule will not execute.

I also have a question about your rule. Did you really mean for the dehumidifier to only be off for 10 seconds?

1 Like

Thanks’s I will give that a try. I am running Rule Machine 5.1, is there a newer version? I do have some rules running on Rule Machine Legacy, they work fine but I should get them moved over.

That dehumidifier has a busted controller that will throw an error every once and a while. When it throws a code the power draw drops to a single digit. If the second dehumidifier I have is running then I shut off the first for 10 seconds to clear the code and turn it back on.

1 Like

There have been RM 5.1 updates and bug-fixes in nearly every hub platform release.

1 Like

Download the Hubitat app