🚿 Bathroom Humidity Exhaust Fan


Nice work!! Glad it is all working for you… thanks for sharing your set up :+1: :wink:

1 Like


Just posting my set up now as promised. I will update this in the next few weeks as I am waiting for some items so I only need to use one ESP32.

thank you for the script. I’m trying the 2.2 version. if this does not work, I’ll try the script.

thanks, I’ll let you know

@Blacky hey. I have updated to 2.2 and am just going through testing/configuring. I dont know if I am an edge case, if so please feel free to ignore me, however, regarding the ‘Manual Fan Switch’ section, for me this is turning on the fan speed high (I have a Shelly 2.5 to control high speed and low speed of the bathroom fan (one device but stepped speeds), the Shelly also therefore shows me when the light switch is turned on). I have configured ‘Fan Switch’ to be the high speed fan and ‘Input - Fan Speed - Low Speed Switch (Optional)’ to be the low speed fan HA entities. The problem is, with having ‘Manual Fan Switch’ enabled, when I turn on the bathroom light switch the high speed fan is being turned on but because the low speed fan is not also turned on the fan doesnt come on at all. For full clarity, I did also enable the ‘Use The Fan Speed Options (Optional)’ and set that to the first option (‘switch to low speed then turn off’).
I tried reversing the selected entities in the ‘Fan Switch’ and ‘Input - Fan Speed - Low Speed Switch(Optional)’ fields and the low speed fan then came on when enabling ‘Manual Control’. I think maybe the logic needs reversing when a low fan speed option has been selected higher up?

FAQ - Can you show us your full set up?

Below is one of my bathrooms. I will show all my controllers (ESP32), sensors, setting along with the settings for my sensor light as it all works together. I will try an document as much as possible for you. If you need more information just let us know. It is a big read so maybe make yourself a coffee first.

NOTE: I am waiting on some parts as they have just been released and I am updating my systems. When I receive them I will update this post, so if your interested then maybe check back in in a few weeks.

:gear: The Controller And Sensors

All the items are from m5stack. I have spare controllers and sensors if they need to be replaced ASAP.

ATOM Lite ESP32 IoT Development Kit


ENV III Unit with Temperature Humidity Air Pressure Sensor


Dlight Unit - Ambient Light Sensor


PIR Motion Sensor


ATOMIC PortABC Extension Base


I2C Hub 1 to 6 Expansion Unit


:camera: The Bathroom

Below is one of my bathrooms. Note, the linear slot diffuser directly above the shower head, this is critical for the automation to work correctly. It is connected to my exhaust fan and sucks air over the sensor when the fan is ON. Inside this linear slot diffuser is my humidity sensor.

Below shows the LED lighting. They are separated into segments… the mirror, under the vanity and in the niche

Inside the linear slot diffuser the cable passes through into the cushion head. This cable is in the ceiling space where the ESP32 is plugged into mains power.

I have cut out one of the slots so the sensor finishes flush with the face of the linear slot diffuser. I also painted the cover of the sensor black to hide it and drilled some small holes in the other side of the sensor cover to allow for good airflow trough it.

Below is the sensor fitted to the linear slot diffuser.

Under the vanity is my LUX and motion sensor.

:memo: The code used in the ESP32 (atom light) and esphome

This is for the humidity sensor, temp sensor, LUX sensor, motion sensor, door sensor and the “Manual Fan Switch”.

## "#" = Item - "##" = Note - "###" = DEACTIVATED option

  name: bed2-ens
  friendly_name: Bed 2 Ensuite

  board: m5stack-atom
    type: arduino

# Enable logging

# Enable Home Assistant API
    key: !secret encryption_key

# Over The Air Password (Stops somone on your network accessing files)
  password: !secret esphome_secret

# Wifi Information
  ssid: !secret wifi_ssid
  password: !secret wifi_password

## Optional manual - Static IP
###  manual_ip:
###    static_ip: ?.?.?.?
###    gateway: ?.?.?.?
###    subnet:

# Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "bed2-ens"
    password: !secret fallback_ap_password

# Captive Portal
## After 1 minute of unsuccessful WiFi connection attempts, 
## the Atom Lite will start a WiFi hotspot (with the credentials from your fallback).
## Use your AP (Access Point WiFi) SSID & Password to connect then go to in your browser.

# This is for sensors plugged into I2C Hub 1 to 6 Expansion Unit - It can be tricky

  sda: 25
  scl: 21
  scan: true

  - platform: bh1750
    name: "LUX Sensor"
    address: 0x23
    update_interval: 10s

  - platform: sht3xd ## sht3xd is for a ENV III - sht4x is for a ENV IV
      name: "Bathroom Temperature"
      id: bathroom_temperature
      name: "Bathroom Humidity"
      id: bathroom_humidity
    address: 0x44
    update_interval: 60s

  - platform: qmp6988 ## qmp6988 is for a ENV III - bmp280 is for a ENV IV
      name: "Bathroom Pressure"
    address: 0x70 ## 0x70 is for a ENV III - 0x76 is for a ENV IV
    update_interval: 60s
    iir_filter: 2x

# This is for the physical switch on the wall and to allow for control in a HA dashboard
  - platform: gpio
    pin: GPIO23
    id: bathroom_manual_control 
    name: "Bathroom Fan - Manual Control" # Link to the binary sensor below
    icon: "mdi:fan-clock"

# The physical switch on the wall
  - platform: gpio
      number: GPIO33 ## Wire from this pin to the push button on the wall and back to ground on esp32
      inverted: true
        input: true
        pullup: true
    name: "Bathroom Fan - Bypass Wall Button"
    icon: "mdi:gesture-tap-button"
    on_press: ## on_press is for a push button switch. on_state is for a toggle switch. Choose on_state or on_press for the type of wall switch you have, you can only use one or the other.
        - switch.toggle: 
            id: bathroom_manual_control # Link back to the switch above
      - delayed_on: 10ms

# For a motion sensor in bathroom
  - platform: gpio
    pin: GPIO19
    name: "Motion Sensor"
    device_class: motion

## You can add another "gpio" on pin 32. This can be used for a door contact sensor. 
## I am not using a door contact sensor it is just there to show you how to use it if you require one. 
## For me I am using this pin for another motion sensor located in the WIR to turn on lights.
  - platform: gpio
    pin: GPIO32
    name: "Bathroom Door"
    device_class: door

:shower: The Bathroom Humidity Exhaust Fan Blueprint Settings

Below are the main sensor settings for the automation. I dont have a fan with different speeds so nothing is entered into the 2 “Input - Fan Speed” selections. If you have a fan with different speeds then you would enter them in here. I do use the “Maximum Humidity” in the settings so I have entered in my humidity sensor into “Input - Bathroom Humidity Sensor”.

Below are the main settings. I refer these setting as “Summer Mode” but the are not labelled like that as it is just easer to read this way.

Below is to enable winter mode. I use it but you don’t have to use it as it is an option.

Below are the winter settings.

Below are the light settings. I dont use them as I use my :bulb: Sensor Light blueprint to control the lights with the “Automation Link Option”.

Below is the manual fan switch settings. This is the switch I created in the ESP32 code and wired to a physical switch on the wall.

Below is the “Automation Link” settings. This will be referred to later when showing my sensor light set up. I have set this to 2 minutes. This allow us to dry ourselves before the motion sensor is able to detect motion again once we move to the other side of the glass shower screen. I have created a toggle helper for this.

I have entered in a by-pass but realy don’t use it now we have developed the manual fan switch.

:bulb: The Sensor Light Blueprint Settings

Click here for my :bulb: Sensor Light blueprint.

Below is the main settings. Trigger is the motion sensor under the vanity and in the ESP32. You can see my 3 LED lights entered in. The main light is controlled manually as we use the LED light most of the time and only turn ON the main lights when needed.

The light settings

The by-pass settings. This is where the automation link in the bathroom humidity exhaust fan blueprint controls and takes over this automation disabling it. I have selected to turn the lights ON as this allows it to work without ever knowing anything is happening. Note the by-pass time delay of 1 minute. This allows for when the by-pass is turned OFF for us to trigger this automation again before turning OFF the lights.

Sun options, don’t use them in this automation.

This is the LUX sensor under the vanity and in the ESP32. Selected “YES” as this sensor is affected by the lights.

Time options, don’t use them in this automation.

Device tracker, don’t use them in this automation.

Night Light main input settings.

Night lights, light settings for lower softer lights at night.

Night light conditions. 2 iPhones used to enable the night lights when they are in do not disturb.

And that is it :partying_face:. If you got this far you have done well :rofl:

Hope this helps you set up your automations


Blacky :smiley:

Back to FAQ: Click Here



The manual switch can not control the fan directly. You can’t use the switch connected to the fan. It has to be stand alone and it will only turn the fan ON and OFF. Low speed will not run.

If you would like to test it you can create a toggle helper and use that toggle as your manual switch.

If you are happy with it, you will probably have to add another Shelly in… like a Shelly plus 1 and wire another switch (or connect it to the existng fan switch and disconnect the other Shelly 2.5 to the switch) to it and connect it to nothing. Then use that switch to turn ON manual control.

Hope this helps.

Blacky :smiley:

1 Like

@Blacky thanks for the info.

I love your bathroom! Looks like you live in a hotel!

Question regarding ‘Automation Link - By-pass Control’ - can an automation be used as one of the entities? Automations can be turned on and off like an input_boolean. I use the Toilet Exhaust Fan blueprint and wondered if adding the blueprint automation into this field will simply turn the automation off and on as needed?


Yes but you will need to edit the code. The reason I say this is if your using my :toilet: Toilet Exhaust Fan with time delay there is no by-pass yet… yes it is on the road map and I will make it work with this blueprint :infinity:. Rather than edit the code I would suggest you create a template sensor that will do this for you, that way you never have to edit the blueprint code. It make it easer when updating. If you are not sure how to do this just reach out and I will provide the code for you.

FYI: When we enable and disable an automation it preforms not action, so it is basic function and not my recommendation. When we use the by-pass in my blueprints you have options, on what to do when you turn them ON (smart function). When we turn the by-pass OFF the blueprint analyse the automation and all your settings and tries to preform the correct action (smart function). So this is not realy good automation to enable or disable automations, just basic function. So if there is a by-pass I would recommend to use it rather than enabling and disabling an automation.

Blacky :smiley:

1 Like

ended up using the script! this works, thanks

1 Like


Thanks for letting us know… glad you are up and running :partying_face:



1 Like


This :toilet: Toilet Exhaust Fan with time delay blueprint has now been updated so it will work with this blueprint now. Just need to create a toggle helper and enter it into both blueprints. More information can be found in its thread Click Here.

Blacky :smiley:

1 Like

Very interested in trying this, do you think it would work using the Sonoff Humidity sensor instead of the one you listed?


You can use other humidity sensor and you don’t have to use the one I use but it must report at least every 60 seconds or on every state change.

I did a quick google search and still not sure what your sensor does. Your humidity sensor must report a value at least every 60 seconds. Some battery sensors report on every change and I think your one reports on 5% of change even when they say it report every 5 seconds. If it is 5% change then no it will not work. The best way it to see what your sensor reports.

i use the aqara Humidity Sensor works great.

1 Like

I am stumped at selecting the Fan switch

I cannot select it (a Sonoff ZBMINI relay) which works via the Dashboard:

I have scrolled through all the dropdown for device and entity and tried typing Fan, MINI, Bathroom

Screenshot 2023-10-11 115913

Replying to my own question LOL

I went and checked the entity for the switch and then copied and pasted - seemed to accept it

1 Like

@Blacky can I also use the derivative of an absolute humidity sensor? Currently the “rising” and “falling” has the % unit of measurement. If I use absolute humidity, the value will be a change of 200 mg/m3/minute or so, instead of 5%/minute.

Why absolute humidity? Value change is “sharper”; relative humidity value is damp(en)ed due to temperature rise that comes with it when taking a shower. A 5% relative humidity increase combined with a 2 degreeC increase is a 24% increase of absolute humidity (50% to 55%, 20 to 22 degC). See Absolute Humidity Calculator

1 Like

@Blacky I am testing your blueprint out, and I have a manual binary switch setup in ESPhome called “binary_sensor.bath_sense_fan_10” The setup looks like:

  - platform: gpio
    pin: D0
    name: ${display_name} Motion
    device_class: motion
  - platform: gpio
      number: D3
      inverted: true
        input: true
        pullup: true  
    name: ${display_name} "Fan 10"
      - delayed_off: 250ms
  # Simple
      - homeassistant.event:
          event: esphome.button_pressed
            title: Fan button was pressed 

I tried and pressed the temperature-open push button, but the fan did not turn on. Do I need to make the filter delayed_off longer than 250ms?
And do I insert a motion sensor somewhere in the blueprint? I do have a binary sensor in helper to bypass the motion sensor, setup I have is in node-red. In node-red I have disabled my fan on and off nodes.

I think I have to change the ESPhome to toggle switch, and not nomally open. It is a physical nomally open push button.

wonderful blueprint BTW!


Give it a try and see what happens. There are many reasons why we use a Derivative Sensor and to date it just works.