Detecting the end of a shower and turning off the bathroom fan

I’m using the Aeotec Multisensor 7 and I seem to get a decently sharp rise in humidity level when someone takes a shower, which I should be able to use to trigger the bathroom fan ON.

However the humidity fall rate at the end of a shower is verrrrry slow, even with the fan on, door open, window open, etc… See below it takes 12+ hours to return to ambient humidity (cyan and magenta lines are humidity in other parts of the house)

I don’t think it’s practical to use humidity trend alone to turn OFF the fan. I’m wondering about incorporating motion detection in the condition to turn off. I get pretty reliable motion detection events while someone is moving around in the shower:

So perhaps the two below conditions ANDed could work well?

  • after a period of no motion events (10 minutes?), and
  • when the humidity has a sustained downward trend

Any ideas for how to make this automation robust?

Perhaps you need a more powerful fan if it’s not reducing the humidity quickly enough? Also, have a look at this blueprint

It does exactly what you want - I’ve been using it for some time now and it works great.

1 Like

Is the above graph with or without the fan on?

I use an Aqara Temp/Humidty/Pressure sensor for this same purpose and just cut the fan off when humidity dips below 60%. I also use the fan as an indicator for when someone is sitting still on the “throne”. I also have pets so that is why I have different times for lights and the away toggle so the animals don’t turn lights on when we’re away.

My Bathroom logic:

A sustained flat trend should do the trick as well I would say. But I took another approach that I copied from my previous home automation system, and it works quite well so I don’t feel the need to change it:

A fixed lower hunkdity limit is not a good way, because the normal relative humidity varies with outside weather. So I look at the humidity level in an adjacent room as a baseline. If the bathroom is significantly more moist, I turn the fan high, once it comes within x% of the baseline from the other room, it stops 15 minutes later.

I thought the same about the fan but it’s well sized to the room and certainly feels like it’s dealing with the humidity well (air subjectively feels dry, no condensation on the walls/windows, etc). There’s also other posts of people reporting very slow fall rates with humidity sensors - I wonder if a bit of condensation on the sensor results in it taking a long time to read levels representative of the room.

Thanks I’ll check out the blueprint.

I left the fan off for the duration of the shower and then I turned the fan on after the shower to see the effect it had and left it running overnight. You can see the humidity start to drop at that point around 7:15pm. I also opened the door around 11:15pm to help the air mix with the rest of the house but it still takes 12+ hours to return to ambient.

Thanks for sharing your config, I’ll need to study this.

I’ll certainly use my other humidity sensors as a reference for turning on, that seems reasonable.

The challenge I foresee with using “returning to within % of reference” is that if I use within 10% lets say, in the above graph my bathroom fan has to run for 4+ hours before it meets that. If I use a larger value like 30% then let’s say it’s a humid summer day outside and the ambient is 80% humidity then I will satisfy that condition always and it’ll turn off prematurely.

you can use the derivative sensor to get a good trend.

then you can use a negative value for the desired time to trigger the fan off automation.

the only issue with the derivative sensor is that there is a “bug” that if the input value never changes the derivative never goes to 0 but that shouldn’t be an issue in your case. just something to be aware of.

Take a look at the HACS Integration “Generic Hygrostat”

I have been using this for a couple of years now and it works really well.

1 Like

If it takes 4 hours to come anywhere near the baseline, your ventilation is not performing as it should. Have you considered the location of the sensor, is it in a place that is not representative of the rest of the bathroom? Looking better at the time scale in the graph, it seems your ventilation is mediocre at best, because the rise is steep but de decay is slow. Or is your sensor in a position where it can collect steam and get wet itself? That is also not good.

It will always take hours to reach the baseline, but the question is: should it, if it is not too different. Once the difference is small, it will always take long. That is because the air you get in is barely different from what is in the bathroom already, and it will mix with it when the fan sucks it out.

So the point is: when you are close to the baseline, accept normal ventilation will do the rest. You should be able to do that with either a trend sensor, derivative (on which the trend sensor is based) or a treshold approach with a proper baseline.

Based on how it feels in the room I have to say the ventilation is performing so I think the slow decay must be from sensor placement. It’s recessed in the ceiling about 1.5 feet beyond the shower door and I imagine it’s possible steam can condense on the sensor in the moments before the fan kicks on.

I’ll look at what my options are for relocating it.

With fan size you have to have air in to take air out.
how is the fan installed in a wall and straight out or a flex duct?
thats where i would look first.

I think you may be correct about the placement of the sensor and condensation affecting the readings. I use the Xaomi LYWSDCGQ BLE Temperature & Humidity sensors and find them very reliable and accurate. They update the readings every few seconds and I feed them into derivative helpers which gives a very clear signal of when someone is taking a shower:

With the change in weather recently (rain) my humity values above meant that the fan was always on. I created some template sensors and helpers to fix my issues.

I created a binary sensor that compares the bathroom humitity to my ecobee humidity value plus helper offset value so it doesn’t take a long time to get right down the the value of the ecobee, which it nevers seems to. Standing water in the tub/shower/toilet will cause this to take a long time. Currently the helper is set to 10. The threshold sensor is just for info so i can compare on a history graph.


  - binary_sensor:
      - name: Bathroom Fan Humidity Trigger
        state: '{{ states("sensor.bathroom_humidity_sensor_humidity") | int > states("sensor.thermostat_current_humidity") | int + states("input_number.bathroom_humidity_trigger_offset") | int }}'
  - sensor:
      - name: Bathroom Fan Humidity Threshold
        state: '{{ states("sensor.thermostat_current_humidity") | int + states("input_number.bathroom_humidity_trigger_offset") | int }}'
        unit_of_measurement: '%'

The values shown in the graph below are not accurate for the actual funcitng of the fan but you can see me playing with the helper and when the threshold would be crossed to cause the fan to come on.

Before I used this blueprint I had created my own logic using a derivative sensor and set a maximum run-time of 30 minutes. My sensor is in the shower because I think it’s better to start the fan as soon as possible to get the airflow going rather than running it for an extended time afterwards trying to get the humidity down. I also use a Shelly 1 as the switch and set a 30 minute maximum runtime on it.

Since switching to the blueprint it’s been working well. The only issues I have are when 2 people take a shower, one right after the other - it often won’t come on for the second person, presumably because the humidity didn’t drop enough in between showers. In those cases I just manually flip the switch and let the Shelly turn it off after 30 minutes. If you look at most commercial bath fan timers they provide for anywhere from 5 - 60 minutes of runtime, with many only allowing 15 minutes as the max. I’ve never seen moisture on the walls or mirror, so I believe it’s working as expected.

That pretty much echoes my experience. My humidity sensor is about a metre from the shower, so it can take a minute or two before the fan kicks in. However, it doesn’t cause any problems and there is no sign of the mould problem we had when the fan switched on and off with the lights.
We work on different shower schedules, so the issue with the second shower not triggering rarely arises :slight_smile:

Don’t know if it was mentioned, I just use a temperature sensor on the warm pipe that goes to the shower. If it’s hit, turn fan on. If it drops (which is always pretty quick) I turn off the fan after say 10 minutes. This assumes you have access somewhere to the pipe. If it’s for the complete bathroom you can still use it ass added sensor next to the humidity.