Help with Vent Fan Rule

I have what I think is a very simple rule that compares 2 humidity sensors: one in the bathroom & another in the hallway. When humidity in the bathroom in comparison to the hallway is >= 20, then turn fan on. It then waits until that difference is <= 15, then turns fan off. But, if someone manually turns the vent fan on and humidity never reaches the 20 difference, then the vent fan will never turn off (unless the person remembers) since the rule is never triggered in the first place.

How would you rewrite this rule so it takes this scenario into account? I could write a second rule, but I was hoping there’s a way to do it all in one. Thank you!

I turn the fan on when there is motion in the bathroom and turn it off after 5 minutes if the humidity comparison shows low humidity. That pretty much gets around the manual turn on issue since it's almost impossible to turn on the fan without tripping the motion sensor which kicks off the rule.

1 Like

I'd include a private boolean required expression where the private boolean is true/false (whatever you choose). Then in a second rule, detect the fan/vent being manually turned on, switching the private boolean of this rule you have shown to whatever value stops it from being triggered. You could then include in this additional rule a timeout period where you adjust the PB again and turn the fan/vent off.

Detecting the manual operation of the fan/vent is key, and may involve a separate variable to stop the second rule from triggering.... Not ideal, but may be necessary....

1 Like

Thank you! This gave me an idea. The problem really is triggering the rule and a motion detection would solve that even if I don’t necessarily turn the fan on right away. I just need the rule to be running with my current trigger event as a condition within the rule.

I found the Smarter Humidity Fan app based on your initial response. I am totally up for not reinventing the wheel with RM so I’ll have to check that out :slight_smile: Thank you for the tip!

1 Like

That also what I use, though for my garage dehumidifier...

But good pickup of that app rather than the more complicated rule I described. :slightly_smiling_face:

1 Like

@HarleysWorld

This video explains EXACTLY what you want to do...

1 Like

Haha that’s where I stole the rule from. The scenario is basically: my husband turns the fan on manually. He either still hasn’t bought in with the whole automation thing or he just forgets it’s there. He then leaves it on for a while, but forgets to turn it off. This rule never turns off the fan if the difference in humidity never reached 20 because the rule is not triggered in the first place. I could lower the threshold so the rule is more likely to fire, but I THINK this change I added would work. I added turning on of the vent as a trigger event, but the rule only turn the vent fan on if it isn’t already. Then, it goes through the same conditions for turning it off. I’d have to test it.

Well you need to take a shower first and see what the humidity reaches and then compare that to the hall one. Guessing doesn't always work. I know with my showers I usually get to around 78% and my hallway is at about 54 but I simply use within 15% to turn it off. I also have a separate rule that states if the fan is turned on manually, then it turns off with 10 mins of no activity from the motion sensor.

1 Like

Yeah honestly the easiest thing to do is probably lower the 20 to something else so the rule always triggers. I’ll have to creepily pay attention to the humidity sensor every time we take showers to get a better idea of an average.

1 Like

These challenges usually surface when we insist on encapsulating the whole automation into one (stateful) rule. I recommend instead multiple (stateless) rules. One (or more) rule that decides when the fan needs to turn on and others when it needs to turn off. The state is held by the switch itself and the rules only hold the conditions for transitions.

Here’s what I do to handle the manual case:

Notice the rule triggers on physical on (someone flipped the switch) or any off (meaning if the humidity threshold is met it will still turn off) and takes advantage of retriggering cancelling the delayed action .

I was tracking my setup in Grafana for a while and thought about triggering on the rate of increase instead of a threshold but in fact the 20/15 has not failed in the couple of years I’ve been using it.

1 Like

I did not realize the Physical Switch option! This is exactly what I need. I guess I’d didn’t scroll down far enough. Thanks for the tip!

1 Like

Or run the shower for 10 mins and just wait

My solution to the vent fan was rather complicated. But since I finished it, it seems to be bullet-proof.

The first part of my solution was to record the differential between the bathroom humidity and the ambient humidity (provided by Nest thermostat) to a global variable with one rule:

Step 2 was to create a rule that turned the fan on and off based on the humidity differential, but also contained logic to alert people that an automation was running by changing the LED color on the paddle switch while the automation was engaged. There's also logic that allows the automation to complete properly if the fan was manually turned off:

And then if somebody accidentally turns the fan off and then turns it back on while the automation was running, this rule resets the automation allowing it to continue as usual. It also takes into account via required expression that some people might want to manually turn the fan on. This ensures that if the automation was not already triggered, a manual activation of the fan does not reset the automation like it does when the automation was already running.

I started to go down the path of wanting to run the vent until the humidity dropped, but then I just decided to go simple (KISS principle). I just turn automatically turn the vent off after 25 minutes, without regard to the actual humidity. But I'm open to something better.

I second the Smarter Humidity Fan app. The revised fork by @jtp10181 ....[APP] Smarter Humidity Fan *FORK for Testing* allows you to compare the bathroom humidity to another sensor, like the one in your hallway. I have been using it for some time and it works great.

This fork, like the original app developed by @erniemiller, allows you to set a max runtime on the fan. This option will shut off the fan if the lower humidity setpoint is not reached within a set amount of time.

1 Like