Explanation of what a Boolean is

I am fairly new here and slowly learning the huge potential of rule machine. Can somebody explain what Boolean is and what it is used for? Thanks for the help in advance.

"Boolean" in general just refers to a variable that has two values, conventionally labeled true and false. Rule Machine has a "private Boolean" built in to each rule. Here "private" means that the variable belongs only to that rule (often "private" means that it can't be accessed from elsewhere, but that's not quite true: other rules can modify the PB of another rule).

How you use it is up to you. The effect would be little different from if you just created your own variable (and you can indeed create local variables, including a Boolean, within a rule, or a global Boolean variable accessible from all rules). There are a few examples in the docs (which I recommend reading), one of which is to track whether your actions have already run and then not do them again until you "reset" the variable. You can use it to track anything you want as long as two possible values are sufficient.

Also, a small history lesson: in old versions of RM, PB did something on its own: your rule just wouldn't run if it was false. In modern RM, you must do something with it--e.g., check its value with an IF in your actions--to create whatever effect you want. So, be careful if you find any pre-Rule-4.0 examples. :slight_smile:

8 Likes

I use mine in a rule to prevent another rule from constantly running.

I have a power monitoring outlet on my wash machine. The rule basically looks for power above 10 watts to be on, and below 1 watt is off. That window allows for the soak cycle, lifting the lid to add something, and so on. Basically anything over 10W means the timer is running on my machine. Below 1W and the machine has completed its cycle.

That output is then used to trigger a different rule to change the water heater from Eco mode to High Demand mode. If I tried to just use "above 10W" for the water heater rule, it was constantly flip-flopping between the various modes. The Private Boolean makes the decision whether things are truly in use or not.

1 Like

Thank you Sir i learned something new
ok i have a question how do you create a PB
and through some playing connect it

Thanks for the explanation. That makes perfect sense now.

You set the PB of a rule. It’s not something you create like you would a virtual switch.

A Private Boolean can be a trigger for a rule.

To set a Private Boolean, you select it as an action, and the choose the state. It’s also possible to set the Private Boolean of the rule you’re working on, or another rule as mentioned.

To check a rules Private Boolean, you make it a condition.

3 Likes

Thank You so much

1 Like

Thanks guys for the detailed explanation. That’s why I love this community so much.

3 Likes

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