---
title: "Bathroom fan by humidity rise"
description: "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."
canonical: "https://realhomeautomations.com/en/projects/bathroom-fan-turns-on-with-humidity/"
language: en-US
updated: 2026-11-23T16:24:03+00:00
---

# Bathroom fan by humidity rise

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.

> Canonical HTML page: https://realhomeautomations.com/en/projects/bathroom-fan-turns-on-with-humidity/

- **Difficulty:** Intermediate
- **Build time:** 45–90 minutes
- **Reading time:** 7 minutes

## Tools required

- Home Assistant (With access to helpers, blueprints and automations)
- A humidity sensor in Home Assistant (We use the Aqara FP300 through ZHA; any sensor with humidity in % will do)


## What readers will learn

- Turn humidity into a rate of change (%/min) with a Derivative helper
- Set up a fan blueprint that triggers on a rise, not on a fixed threshold
- Set a switch-off time and a fallback threshold for back-to-back showers
- Read the automation trace and tune the thresholds to a real shower


## Skill requirements

- Adding a sensor and a relay in Home Assistant
- Importing a blueprint and filling in its inputs
- Reading a sensor graph in the history

## Project kit

- [Smart WiFi relay Sonoff MINIR4, 10A, 1 channel](https://realhomeautomations.com/en/product/smart-wifi-relay-sonoff-minir4-10a-1-channel/index.md)

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:

- When the rate goes above **+0,9 %/min**, the fan turns on. This is the start of the shower.
- When the rate falls below **-0,8 %/min**, a countdown starts and after 10 minutes the fan turns off.
- If the drop does not happen within 20 minutes, the maximum-time protection skips the wait and goes straight to the countdown.
- 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](https://realhomeautomations.com/bg/produkt/aqara-presence-multi-sensor-fp300-ps-s04d-ai-presence-sensor-dual-mmwave-pir-technology-thread-and-zigbee/) 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](https://realhomeautomations.com/bg/produkt/smart-wifi-relay-sonoff-minir4-10a-1-channel/).

 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

- [Home Assistant: Derivative integration](https://www.home-assistant.io/integrations/derivative/)
- [Home Assistant: blueprints](https://www.home-assistant.io/docs/blueprint/)
- [Blackshome: Bathroom Humidity Exhaust Fan, a thread in the Home Assistant forum](https://community.home-assistant.io/t/509992)
- [Blackshome: the blueprint in a GitHub Gist](https://gist.github.com/Blackshome/8e09a8213b834f1be4ab49ba880abed8)
- [Home Assistant: ZHA integration](https://www.home-assistant.io/integrations/zha/)
- [SONOFF MINIR4](https://sonoff.tech/product/diy-smart-switches/minir4/)
- [Aqara Presence Multi-Sensor FP300](https://www.aqara.com/en/product/presence-multi-sensor-fp300)

 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.