Best Way to Prevent Rule Retriggers During Wait Timeout – Is Private Boolean Reliable?

Hi everyone,

I have a Rule Machine automation where I want to block retriggers while the rule is in a Wait state (with a 3-hour timeout). I’ve been using the built-in Private Boolean to achieve this, setting it to false at the start of the rule and true at the end.

It hasn't been working recently, so I was looking at it, and I'm pretty sure that my Private Boolean had been stuck on false for months—so the rule silently never ran. I’m not sure why it got stuck, but it makes me wonder if this is the best approach. Perhaps the Private Boolean got stuck on false because the hub rebooted while it was in the Wait timeout?

Here’s the relevant logic:

Trigger Event:

  • Temperature of shed area Sensor reports <= EcobeeSensor: Thermostat - 2.0

Actions to Run:

IF (Private Boolean = false) THEN
    Exit Rule
END-IF

Set Private Boolean to false
Set outside-temp to shed area Sensor Temperature 
Set inside-temp to EcobeeSensor: Thermostat 

IF (Temperature of shed area Sensor < EcobeeSensor: Thermostat  - 2.0) AND
   (Temperature of EcobeeSensor: Thermostat > 23.5 OR
    Operating state of EcobeeTherm: Thermostat is cooling)
THEN
    Notify iPad, iPhoneJ:
      "It's %outside-temp%° outside at 734 Alexander, maybe open a window to cool the house which is %inside-temp%°."
    Wait for Expression: Temperature of shed area Sensor > EcobeeSensor: Thermostat 
      --> timeout 3:00:00
END-IF

Set Private Boolean to true

This rule is a "Human Actuated Window Opener," where the obedient male carbon-based lifeform is the actuator, opening a window to cool the house for the benefit of the female carbon-based lifeform.

My main question is: is Private Boolean a reliable way to block retriggers during a Wait, or should I use a different approach (like a local Boolean or Required Expression)?

You don't need the conditional at the start. Just use a required expression of Private Boolean True then have your first action to set it false. I've used that method plenty of times without issue.

1 Like

While the Reqd Expression technique should work perfectly fine (it always has for me too), Bruce has lately been recommending using the PB as a Conditional Trigger instead.

As I understand it, that offers some better "protection" vs a Reqd Expression in some cases (though I don't know details).

2 Likes

Yeah, now you mention it I remember that post some weeks back. I think I modified one of my rules at the time to try it.

1 Like

I have a number of rules that use the private Boolean to prevent re-triggering. I have noticed that there are times when a long delay is running (in my case, a bathroom fan running until humidity levels in the room and outside the room are equal) where I've had some issues if I do a reboot or otherwise mess around with things, as the Boolean stays false. For most of my rules, the delay before setting the Boolean back to true is much shorter, so there's not as much a chance of an issue.

Either way, something to be aware of if you update or otherwise reboot in the middle of rule execution.

Should I have another rule that runs daily at 5am to reset the private Boolean? (Last I checked I also couldn’t figure out how to access the private Boolean of a different rule.)

I'm guessing because it's, well, private.

I’ve done that in the past - not a bad idea if you’re concerned about it staying false.

I do an overnight rule like this in an abundance of caution, since I had that rule already in use to refresh some stuff and reset some other statuses as necessary. I like it as a warm-fuzzy, but it shouldn't be necessary per se.

You can set true/false for some other rule's PB as a Rule Machine Action, but you can't use some other rules's PBs in as a Condition(al) in a rule.

2 Likes

Why encumber your rule with an unwanted trigger event? PB false, do not even bother with it.

image

Then set your PB true when you are ready to proceed.

1 Like

This post just reminds me how much easier things like this are with Webcore. I used a few of my existing devices to demonstrate, with a thermostat and a temp sensor.

Just pointing that out, I don't expect you to use it instead.

1 Like

I have had the same issue with the Private Boolean getting stuck, when using it as a required expression. As mentioned I have since switched to using the conditional expression method to prevent the Boolean from getting stuck. I also add an addition trigger for a system restart with a conditional trigger of the private Boolean being false. The first action can then be if the private Boolean is false set it to true and exit rule.

So if there is a reboot while it is false the restart it will get it reset. You could also do this with a certain time trigger. Every day at midnight, trigger if the private Boolean is false.