7 min read

The bathroom fan turns on by itself when the humidity rises

The fan turns on when the humidity in the bathroom starts to rise quickly, and stops after it drops, with no fixed threshold for the whole year. You use a humidity sensor, a Derivative helper and a ready-made blueprint.

Level
Intermediate
Active time
45–90 minutes
Home Assistant required
Yes

After a shower the mirror fogs up, and the fan is either not on or is left on. A fixed threshold like “above 70% humidity” does not work: the bathroom is different in summer and in winter. It is more reliable to watch how fast the humidity rises, not what it is at the moment.

How it works

Home Assistant does not look at the humidity itself, but at its rate of change. A helper of type Derivative turns the sensor’s readings into percent humidity per minute (%/min), averaged over 3 minutes. The ready-made blueprint “Bathroom Humidity Exhaust Fan” by Blackshome (version 2.6) works on this sensor:

  1. When the rate goes above +0,9 %/min, the fan turns on. This is the start of the shower.
  2. When the rate falls below -0,8 %/min, a countdown starts and after 10 minutes the fan turns off.
  3. If the drop does not happen within 20 minutes, the maximum-time protection skips the wait and goes straight to the countdown.
  4. Fallback threshold: if the humidity goes above 80 %, the fan turns on even if the rate is small. This helps with a second shower right after the first, when the humidity has not dropped yet and the jump is small.

The numbers 0.9 and -0.8 are ours. The blueprint’s defaults are 1 and -1. The times (10 minutes of countdown and 20 minutes of protection) are the defaults at our place. Change them to suit your bathroom, sensor and fan.

1. Check the humidity sensor

You need a sensor that Home Assistant sees as humidity in %. Place it out of the direct stream of water and away from the fan itself. At our place it is Aqara Presence Sensor FP300 through ZHA, but any sensor with humidity will do.

Open Settings → Devices & services → Entities, find the sensor and look at its graph while you take a shower. You should clearly see a rise and a slow decline.

2. Make a Derivative sensor

Open Settings → Devices & services → Helpers → Create helper → Derivative sensor and fill in:

  • Name: „Bathroom derivative humidity“.
  • Input sensor: the humidity sensor from the previous step.
  • Precision: 2.
  • Time unit: minutes.
  • Time window: 3 minutes.

The time window averages the readings and smooths out noise. According to the Home Assistant documentation, without it the derivative is calculated between two consecutive readings. This way you get sensor.bathroom_derivative_humidity in %/min. At rest the value is around 0, and during a shower it is positive.

3. Connect a relay for the fan

At our place the fan is controlled by a Wi-Fi relay SONOFF MINIR4.

Install the relay, add it to Home Assistant and check from the interface that the fan turns on and off. You need an entity of type switch, fan, script or input_boolean. The blueprint explicitly does not accept a device, only an entity.

4. Import the blueprint and set it up

Open Settings → Automations & scenes → Blueprints → Import Blueprint and paste the blueprint’s address: https://gist.github.com/Blackshome/8e09a8213b834f1be4ab49ba880abed8. Then choose Create automation from this blueprint and fill in the inputs:

  • Trigger – Humidity Derivative Sensor: The Derivative sensor from step 2.
  • Bathroom Humidity Sensor: the humidity sensor itself.
  • Fan Switch: the relay’s entity.
  • Rising Humidity Derivative: 0,9. Falling Humidity Derivative: -0,8.
  • Use The Maximum Humidity Option: enabled, Maximum Humidity: 80.

You leave the rest as the default. Here is what our automation looks like with anonymised entity names (to paste it, use Edit in YAML):

alias: Bathroom exhaust trigger on humidity
description: ""
use_blueprint:
  path: Blackshome/bathroom-humidity-exhaust-fan.yaml
  input:
    trigger: sensor.bathroom_derivative_humidity
    bathroom_humidity_sensor: sensor.bathroom_humidity
    fan_switch:
      entity_id: switch.bathroom_fan
    include_manual_fan_switch: disable_manual_fan_switch
    include_max_humidity: maximum_humidity_enabled
    max_humidity: 80
    rising_humidity: 0.9
    falling_humidity: -0.8

Result: in Settings → Automations & scenes there is a new automation, enabled by default. Replace the three entities with your own. The value of path must match the path of the imported blueprint.

5. Tune the thresholds to a real shower

Do not take our numbers as ready. Take two or three usual showers and look in the Derivative sensor’s history at the peak on the rise and the lowest point on the drop. Set Rising below the typical peak and Falling above the typical bottom. If needed, increase or decrease the sensor’s time window.

Check

  • Take a shower. The fan should turn on in the first minutes and turn off after the end of the shower plus the countdown time.
  • In Settings → Automations & scenes, in the automation’s Traces, see which threshold triggered it: the Derivative sensor or the humidity above 80%.
  • Wash only your hands. The fan should not turn on.
  • A second shower right after the first. The humidity is still high and the fallback threshold should take over.
  • The blueprint also has a trigger on Home Assistant startup, and the author writes that its protections work after a restart too. Check it yourself by restarting while the fan is running.

If it does not work

  • The fan does not turn on. Look at the Derivative sensor’s graph during a shower. If it never passes the rise threshold, lower Rising. A sensor that updates rarely gives sharp jumps in the derivative; then increase the time window.
  • It turns on for no reason. The threshold is too low or the sensor is noisy. Increase Rising or the time window.
  • It keeps running all the time. If the humidity at the sensor’s location is above 80%, the fallback threshold starts it again and again. The author advises keeping this threshold as high as possible to avoid false triggers. Move the sensor or raise the value.
  • It does not stop in time. The drop below Falling may not happen. Then the protection works: up to 20 minutes of waiting and another 10 minutes of countdown.
  • An error in the log. If in Fan Switch a device is chosen instead of an entity, the blueprint gives an error. Choose the entity.

Limitations

  • Humidity is not air quality. The automation does not sense smells, spray or the toilet.
  • The relay uses Wi-Fi, and the sensor uses the Zigbee coordinator. If either of them or Home Assistant itself is not working, the automation does not start the fan.
  • How to switch it off: stop the automation from Settings → Automations & scenes. The fan goes back to manual control.
  • We have set up the same blueprint for a fan in a storeroom, but that automation is currently disabled and is not part of what is said here.

Sources

The automation from “How it is at our place” is enabled in Marto’s Home Assistant. The configuration, the helper, the traces and the device models were read on 19.10.2026.

At home

MartoSince May 2025

At our place the bathroom fan has worked this way since May 2025. The humidity is measured by the Aqara FP300 presence sensor, which is in the bathroom anyway, and the fan is on a SONOFF MINIR4 relay. Our thresholds are slightly more sensitive than the defaults: +0.9 and -0.8 %/min, plus a fallback switch-on above 80% humidity. In one of the latest traces the fan was started by the 80% threshold and ran for about 21 minutes.

Need a hand?

We can set up and install everything in this project. In some regions we install it ourselves — ask us.

Contact us

Related projects

Smart WiFi relay Sonoff MINIR4, 10A, 1 channel

9,90 €
View parts

What you need

Added to cart

Real Home Automations

Sign in to your account

With a code sent to your email

Continue with Google
or

By continuing, you accept the Terms and Conditions and the Privacy Policy.