How do I change a private boolean that is in the wrong state?

One of my rules has a required expression that its private boolean is true. The rule sets it to false when triggered and back to true when completed. I opened the rule after it had triggered and clicked done. As this initialised the rule, it didn't complete and so now the private boolean is false when it should be true. Am I missing something as I can't find where I can set it back to its correct state? The rule won't run again until I can reset it to true.

As a temp cleanup, create a new rule


Set the Rule to your rule name, Update rule, run actions.
Post your rule to get input why the PB is not being set back to true

Thanks. The rule works and it does go back to true. This is the problem and why (IMHO) there should be somewhere I can force the PB:

1 - The required expression was true
2 - The rule triggered, and set it false as its first action
3 - There is then a wait for conditions to be met before a further action sets it to false

I opened the rule for editing, did nothing but clicked done to exit the page between 2 & 3 above. The logs show that the rule initialised so at that point the rule has been interrupted - the PB is false but the rule won't proceed and complete its actions setting it back to true. As it's a required expression it cannot trigger again.

It's not imperceivable that anyone could open a rule for editing and end up in this situation so it would be better if there were a way in the rule to manually switch the PB. I'll have to rewrite all my rules that use PB to use local variables instead.

1 Like

Does your logs show any errors ? A first pass, rule looks okay; but don't understand need for Run Actions: Notiifcation - Enable

I occasionally run into an issue where a PB is in a wrong state. I created a rule with no trigger where the only action is

IF PB == true
PB = false
ELSE PB = true

So that hitting the action for the rule toggles the PB.

1 Like

I see the same thing occasionally. For me it was usually due to a hub reboot during the PB wait. I created a rule that on reboot sets all my PBs, that use this method, back to true,

3 Likes

It's fine - supposed to be that way. The rule shown sets its own variable to "Wash Cycle Complete". "Run Actions: Notification enable" is a rule that checks the variables within 6 rules (inc this one) and if any are not null, sets a boolean (notificationEnable) to true. notificationEnable going true then triggers actions that displays any non null variable in its own notificationActive variable for three seconds, repeating until notificationEnable is false again. The second "Run Actions:Notification enable" is needed to set the notificationEnable boolean back to false once the sub rule has completed otherwise I'd be left with a notification permanently on my dashboard. This is all so I can have a single space on my dash that scrolls through all active notifications but goes blank when there are none.

Thanks for the suggestions. As this is linked to other rules that little mistake left other rules active. I've replaced the Private Boolean with a Local Boolean. At least that way I can switch it back within the rule instance.

I'm surprised there's not a way to access the PB and change it without using another rule, but anyway it's sorted.

Isn't there a "Run actions" button to manually trigger the rule?

What I plan on doing with my rule that has a PB that sometimes gets stuck is eventually convert it from RM4 to RM5 and just use a hub variable and predicate conditions.

1 Like

@waterboysh I'm already on RM 5.1 and so I've switched the Private Boolean in both the Required Expression (predicate condition as was) and the actions to a local variable (set to boolean). I used local variable, as it is accessible directly in the rule instance, should I need to alter it, whereas a hub variable has to be accessed via the settings page.

I'll need to look at the differences between Local Variable and Hub Variable. From memory a hub variable can have a connector, will keep it's state through a hub reboot and is accessible from other rules whereas a local variable (I think) is only accessible inside the rule in which it is created (which is all I need in this instance). I think hub variables may also use more resource?

I had a rule a while back that I always had issues with using the PB. I finally ended up making a virtual switch and just turning it on and off and that solved my problem and makes it easy to toggle it if you ever need to. Just as an alternate idea.

4 Likes

I will be the contrarian here. I use PB extensively and I have never had a problem. Why use PB? Because of scope. The only possible issue is if the hub is shutdown because of power fail orderly shutdown or during the infrequent firmware update reboots, causing the hub to miss events that would change the PB,

Like @terminal3, I have a systemStart triggered rule that initializes everything (mode, day/night light states, PBs), and runs rule initialize routines. That way, I never have to futz around with things on reboot after power fail or firmware update, regardless of the length of time the hub was down.

1 Like

Is there any benefit of using PB over local or hub variable? Am I right in thinking hub variable might use more resources? I'm not sure if that's also the case for local variable.

They are all pretty efficient. PB’s advantage is (1) it’s free, every Rule has one, so the overhead is already there, and, more importantly, (2) scope is local.

2 Likes

What would truly be nice for PBs would be a little checkbox on the initial rule editing page (maybe down by the Local Variables) that would show the current state of the PB and allow you to toggle it.

3 Likes

Agreed - that would be a good addition. It would save creating a local variable or having a separate rule to reset it. Having it right there in the rule editing page would be perfect especially if it also showed the current state.

@johnwill1 Would it work for you to set up a Rule that triggers on Startup, and then runs the "Set Private Boolean" action to initialize all your Private Booleans to an expected system startup value.

You could also add a "Button pushed" trigger and create a virtual Button named something like "Reset Private Booleans" to trigger this on demand.

I.e., a Rule like the following . . .

1 Like

Yes that sounds similar to what @672southmain suggests and would be easy enough to set up.

1 Like

@johnwill1 ,
I had a similar problem with synchronization of my private booleans when my hub would automatically reboot (I set up a RM rule) when the free memory would get below 300,000kb and another rule would happen to have a private boolean in the false state. I used private booleans mainly in my older RM4.0 and RM4.1 rules (but also in some RM5 and RM5.1 rules) to set “delays” so that my associated notifications would only trigger one time within a given period of time. Because of this, when my hub would restart, some rules would no longer work as their private boolean was set to false.

I can attest that @jvm33 ’s suggestion works as I have been using this method of resetting my local private booleans to true upon restart for about 9 months now. Prior to using a “Reset All Private Booleans to TRUE upon Reboot” rule, I also had a “reset All Private Booleans to TRUE” rule with an auto-off switch as a tile in one of my dashboards so that it could be used as a button to manually reset the PVs to true in case any of the PVs got out of sync for whatever other reason.

The one thing I agree with strongly is that I would hope that there would be an easy way to tell the state of the local private booleans in any of my rules in a dashboard tile. I would settle for an indicator that could easily tell me if ANY of my local private booleans was set to False, or if ALL my local private booleans were set to True. Even though the Set Private Boolean action allows you to select among your rules you wish to set the private boolean to a true or false state, I have not discovered a way in which you can “poll” all the local private booleans to see if any of them (as a group) is in the false state. I would like to have this as a tile in my dashboard next to my “Reset Private Booleans to TRUE” trigger tile to easily see if I need to reset them to true to re-enable any rules that have gotten out of sync.

Anyway, just wanted you to know that @jvm33 and @672southmain ’s suggestions are very easily implemented and have worked for me for several months now. One minor modification I use in my rule however is that I use the formattedUptime attribute in Hub Information driver as a trigger. The formattedUptime tells me if the hub has actually successfully restarted and is operational and not just if the hub has been restarted. If my formattedUptime is under a certain number of seconds, then I have a pushnotification sent to me to let me know that a reboot was done and the hub was successfully restarted (and fully operational as I was able to receive the pushnotification) and all my private booleans were reset to the true state. This also of course informs me when and if an automatic reboot occurs (my reboots occur based on freeMemory available and not on a schedule).

Hope this works for you.

2 Likes