So I think I've got a pretty good handle on Rule Machine and how to utilize it for MOST of my automatons.....but I've been following a few threads that discuss "private boolean" and I'm curious to find out more. I've read the RM Doc on the website but it didn't really help me understand what PB is and how to use it. Can someone please explain to me like I'm 12 years old what PB does and how to use it in practical rule applications for Hubitat. Thanks!!
Private boolean is a simple variable that captures what the state of a rule is; Either the rule is true or false.
It allows you to change the boolean of any rule regardless of the conditions set in the rule. So, let's say that you have a rule that has the conditions of Must be between 06:00 and 11:00 AND contact sensor 1 must be open. In the real world, it's 13:30 and contact sensor 1 is closed. So, this rule would evaluate to false. However, using PB, you can flip that rule to true for the purpose of running it from the rule you are calling from.
I hope that makes sense.
That's not how I'd describe Private Boolean....
I would have probably said something like...
Private Boolean (PB) is part of the set of features to allow Rules to be combined/cascaded/work together.
PB is a switch that exists in each and every Rule that can be manipulated by any Rule. However, PB must be enabled for that manipulation to do anything.
Under Restrictions, down at the bottom, is one of these:
It is disabled (PB is ignored by this rule) by default. PB is also initialized to be True. (Which is what the [true] in the screen cap means) Therefore, enabling PB only, does nothing. It's true, and true means the Rule gets evaluated because of it's events.
When PB is enabled, and something sets it false, that Rule is shut off... as if it got deleted. Set that PB to true again and the Rule will function as intended. A Rule can manipulate it's own PB, or the PB of another Rule.
Imagine a rule that turns on a light from a Motion sensor. Now imagine you want that to work only on school days, unless you override it with a switch.
One Rule to do that is kind of hard because "school days" has to be weekdays minus all the holidays kids get (and that I don't.) So you need a rather large rule just to figure out if today is a school day. But once you have THAT rule working.. add in the override switch and it can be used to True/False the motion/light Rule's PB.
Yeah, MUCH better.
PB is very powerful... and you know the old saying...
"With great power comes great confusion."
no, that's not the old saying.. but it probably should have been.
Ha! You should copyright that though as that's 99% true with dealing with home automation!
Bruce has a recent example here:
Of using PB within a single Rule.
Thanks guys.....This helps, although I think I just need to create some dummy rules and play a little on my own to see the results. I might be back with more questions, but in the mean time I'm off to play with PB! Thanks again!
I always think of PB as an OVERRIDE/PERMISSIVE.
If PB=false (and used as a restriction) the rule won't execute no matter what the other conditions do.
If PB=true it will allow the rule to execute, if the conditions warrant, but it does not actually force it to execute itself.
You can also use PB as a Condition or Trigger Event (wouldn't do this AND use it as a Restriction in one rule).
As a Condition, you get some added flexibility for true and false actions. This is usually done in conjunction with some other rule that is setting the PB.
So many twists.....we need a Youtube Hubitat Instructional Series on PB!
I'll 2nd that.
I've been using PBs to save the status of devices that don't have "toggle" capability:
IF PB=false THEN
turn device ON
turn device OFF
Soooo, a year later — have there been any videos made on Private Boolean, its uses and how to examples?