Private Boolean

It seemed best if I created a new topic instead of extending this prior one, but I'm linking to it for reference.

Measure Duration
(by the way, how do you link such that it shows the mini snippet from the link?)

This is an extension of questions that I was asking about monitoring humidity as it relates to the exhaust fan in my bathroom.

My suspicion was correct that the trigger of humidity > 63 led to the rule triggering every time the sensor sent an update (current device setting is every 1% change in humidity). I searched for debouncing and first had a setup using two rules (managing the recurrence with a virtual switch being on or off). However I was hoping to trim down to one rule using private boolean.

The rule I made had some notifications before, which I was using to debug, but I took them out before pasting here.

I need help with the logic on PBs because when this runs it never gets to the point where it resets the PB to true. At this point there aren't actual switches installed as I only received them in the mail the other day and hadn't installed them yet (thus the name "faux"). I bring that up as without it I couldn't tell if it's getting past that "wait for condition" of the humidity dropping lower. I'm sure there's probably a way to monitor the status of that virtual switch to, but I wasn't sure how to do that either. I'm hoping someone will be able to recognize my error directly from the rule text.

Thank you.

Edit: I now realize that I made that screenshot after the PB was in the false state, and I hadn't reset it (using a separate rule I made just for that), so ignore the state it's showing in the orange [ ]. Well unless I have the true/false logic backwards.

I think part of this might be how Waits work in RM. every time the rule is trigger are cleared out of the system

Copy the link icon (two chain links) at the bottom of the desired thread entry to link the whole tread entry, or, for a snippet, select the desired text, then either copy and tap the quotes icon above your reply/post composition, or tap the pop up quotes icon at the end of your just-selected text, which will start a reply. The rightward-curving arrow in the upper left corner of your reply will let you make the new reply a standard reply, a private message to a user, or a new topic.

1 Like

I think I need more detail. Do you mean how it queues the logic to do the wait in the hub?

@Hasty1 Ohh! I think I see what you mean. So, because it still actually retriggers, it clears the prior wait regardless of the fact that it was waiting. Does that mean the only solution is the virtual switch, or is there some way to restore the wait - maybe an ELSE IF that contains just that condition and also the restore of the private boolean?

Thank you!

1 Like

That is what I mean. I haven't quite woken up enough this morning to logic out the best way to do it, but I think the wait being removed when the rule is re-triggered is what is failing you.

Can you describe what you're trying to do with this rule? Perhaps someone could suggest something that would for for that then. The above is correct that any trigger matching will begin your rule actions from the beginning again and un-schedule/un-subscribe any in-progress "Wait" actions, which sounds like it may be a problem for you (but I'm not sure what the goal is).

1 Like

I am not sure why you keep fighting this humidity thing using RM. If you look over the apps that do this, it is a lot more complex than you can do with a few lines of RM code. I don't think this is the best application for Rule Machine.

That being said, when I do private boolean, I have a separate PB only rule. Then that PB rule is used to trigger a second rule for something like on/off. I know it can be done in one rule, but for troubleshooting purposes, and to reuse the PB logic in other places, I keep things separate.

Pseudo code here, call this rule power PB.

If power level above 50W, set PB true.
If power level below 25W, set PB false.

(that gives me a deadband so I don't get multiple triggers in the next step)

New rule. Trigger is power PB rule.

If PB for power is true then do X.
If PB for power is false then do Y.

Ok I am looking at this again and you are trying to use the PB to keep the rule from triggering multiple times when the condition is still true. You might be better off just saying

IF device is off turn on

To keep from sending multiple ON commands.

The debouncing I initially suggested was to Keep the on and off cycle from short cycling the fan if the humidity was bouncing up and down.

Partly because I consider the programming aspect challenging and rewarding, partly because I still need to install the switches (so it's hard to test anything that's an app until I have those in place), and partly because I must be slightly masochistic.

Thank you for still offering suggestions.

1 Like

I'm attempting to have an exhaust fan turn on when the humidity in the bathroom reaches a certain value, stay on until the humidity returns back to a lower value, and then turn off. The retriggering seems to be because the sensor is above that first value, and continues sending new triggers every time it changes 1% relative humidity (either continuing to go higher, or even as it decreases but before it passes the first limit).

I think the information about how the "wait for condition" resets with a new trigger has given me enough info to do it programmatically, and I will still look into the apps once I have something more usable as far as a switch.

That is what virtual switches are for.

1 Like

I’m actually doing something similar and I have it set up as follows. I have one rule that will capture the humidity when the light in the room goes on. If the humidity goes up by 4% while the light is on then it will capture the humidity again and turn on the fan until the humidity goes back down to the captured value -2. I capture the humidity again at fan start because my motion sensor that provides the humidity sends it every 5 min so depending on timing it just seemed to be a better plan to grab a new value when the fan came on.

This is still a work in progress but maybe it will give you some other ideas too.

1 Like

The following works OK for me and it might help you out. You can ignore the expression about mode NOT being away....I dont want the fan coming on when I'm not at home....

Screenshot 2020-09-11 213024

1 Like

Touché. Just less satisfying on a dashboard than it is to hear a fan come on.

I have been trying to get my head around this “private boolean” and I just don’t get it. Could someone explain what is happening here, I can’t figure it out. I have a rule to give me a notification if the humidity gets above or below a certain range and I get multiple notifications before I can get to the humidifier to turn it on or off. I believe the “private boolean” would help with the multiple notifications but I just can’t make sense of it. Thanks

1 Like

In short, PB lets you analyze something, and set a true or false condition from those conditions. That logic can then be used to limit rules to run only when the logic is either true or false depending upon what you are expecting to happen.

See my power example above. When power goes above 50W, PB sets true, and stays true as long as power doesn't fall below 25W.

So if my wash machine readings are 55, 34, 73, 62, and so on, I know the machine is on. But once it falls below 25W I know the machine is off.

(These are not actual numbers of what my washer does, just an example by the way. So don't try to use those for a real rule.)

So I can take the True boolean, and via a new rule, turn the water heater up higher when I am doing laundry. And I can take the False boolean, and with yet another rule announce "laundry is done".

So you could use this basic logic to do your humidifier. As long as humidity doesn't bounce for some odd reason from "too high" to "too low" you should only get one change, from True (high) to False (low) humidity.

1 Like

I think I am beginning to get it now. I will add it to one of my rules and see what happens.