How I Made My Bathroom Fan Smart

When I moved into my house, it came with this and old fan in the bathroom to keep the moisture down when you’ve had a shower, the bathroom itself is in the inside of the building and doesn’t have any external walls / windows, so the fan is really important to keeping it dry and non-moldy.

The original extractor worked well enough, but I’ve never really been that happy with it; it’s kind of noisy when running at full speed and has a trickle mode that runs it at low speed all the time – ostensibly this is to keep the room fresh, but in reality, means that the room Is always cold in the winter. It’s also not very well installed – is the case not fully closed on the fan focusing, and when I tried to close it up tightly the fan scraped the inside of the case and made an awful noise.

More recently the humidistat that makes it speed up automatically stopped working, meaning that after a shower the room would stay damp for hours afterwards. I’ve tried taking the fan apart and cleaning it in case it was just dust and grime of the sensor. But that didn’t help, so I set about replacing it. This being 2021 with nothing better to do, I decided to make it smart and control it from software.

After some research, I used a Manrose MF 100T inline fan, looking down the spec sheets, it is quieter, more electricity efferent and moves more air than the existing solution so seems like a great fit.

Photo of installed extractor fan in attic with inlet and outlet tubes.

To control the fan, I used a Shelly 1 relay – I’ve used some Shelly 1 PM relays in a couple of other places that I’ll write about soon, and I’ve so far been super happy with their ease of use and reliability.

It was all connected up as shown in this schematic:

Wiring schematic for extractor fan

To make sure that the system was not overly dependent on the smart setup, I used a fan with an inbuilt timer that would automatically start with the bathroom lights and stay on for a short period after they were turned off. As my bathroom lights are using controlled using Ikea Tradfri bulbs connected to a Hue hub and a motion sensor, the switched live feed is effectively always on.

The Shelly 1 relay is then connected to the permanent live of the fan, so that the Shelly is in full control of turning it on and off, but if I ever need to remove the smart setup, the relay can easily be bypassed, and the fan would work completely normally.

Photo of Shelly 1 relay installed in box.

UK building regulations require that as the fan is connected to the bathroom lighting circuit, it be fully isolatable though a triple poled switch, so that was added too.

A quick note here. Mains electricity is dangerous. My fan was installed by somebody who knew what they were doing and complies to local regulations for safety. If in doubt, seek professional assistance when attempting a similar project. The details here are for information only and should not be considered in any way error free or a guide to complete work safely. I take no responsibility for your safety if you choose to do something similar.

Back in the bathroom, I added a Sonoff Humidity sensor on the other side of the room to the extractor. The humidity sensor is connected to my Home Assistant Setup on my Raspberry Pi using a Raspbee II.

With everything connected together, I created some automations to control the fan:

  • Turn the fan on when there’s a sharp jump in humidity

I used a Trend sensor that would switch on if the humidity jumped with a gradient equivalent to 15% in 5 minuets. When this automation is run a helper bool is set to true, so the fan is not switched off with the lights until the humidity is lower again.

  • Turn the fan off once humidity has lowered
    I used two more trend sensors, this time inverted, that detect if the humidity is not tending up or down. When both of these have been on for seven minutes, it means the humidity has stabilised and the fan is switched off. My thinking here is that the fan will eventually reach an equilibrium where the air replacing the air is pulls is at a certain humidity level, so there’s no need to fun the fan any longer.
Humidity graph showing the Landing and stairs stable, while the bathroom has a rapid jump and decline.
  • Turn on the fan when visiting the bathroom
    I wanted the fan to come on if you are using the bathroom so that it can clear any… err… smells. But I didn’t want it to come on if you just popped in to wash your hands (and sing happy birthday), so if the lights (also controlled by Home Assistant) are on for 1 minute, then the fan will start. I also decided to set it up to not run the lights at night time, as not to disturb sleepers.

  • Turn off the fan when leaving the bathroom
    The fan will run for three minutes after the lights are turned off. Unless it is still clearing humidity in which case it will stay in until stabilised.

I’ve shared the YAML for all this in this GitHub Gist.

In all, I’m really happy with this setup. It works really well, the relays have been really reliable, and hopefully I’ll save some money in the winter. I’m still tinkering a little with the exact parameters for turning off the fan, but that’s al part of the fun, right?

There was once a boy, who really loved tractors. He was obsessed with them, he had posters of different makes on his wall, he knew all of the specifications for every one.

One day he got an opportunity to go to a farm and drive one, but when he was driving it, he fell out and broke his arm. After that he hated tractors; pulling down all of his posters and putting up pictures of cars instead.

Many years later, now a grown man, he walks into a bar. Everyone is this bar is smoking and it is thick with smoke. There is a woman in the corner chocking and finding it hard to breath. So he takes a deep breath and inhales all of the smoke then blows it out of the window.

Amazed, the woman asks “how did you do that”

“Well”, he replied, I’m an ex tractor fan.

My brother told me this when I was 7, I’ve never forgoten it.

Feedback

I hope this was interesting, if you have any feedback or have tried something similar, drop me a comment or a tweet on Twitter. If you want to keep up with the latest smart home projects, follow me on TikTok.

2 thoughts on “How I Made My Bathroom Fan Smart

  1. I’ve tried replicating this in my house but with a Shelly H&T Sensor. I can see the bathroom_humidity_stable_up sensor turn on and off, but I can never get the bathroom_humidity_rising to turn on. The H&T is reporting a 1% change in humidity and I can see in HomeAssistant that it’s seeing the increase in humidity values. Any suggestions as to where I can look to figure out why this sensor simply isn’t turning on with a rise in humidity?

    Like

    1. If you haven’t read them already, there docs for the trend sensor in HA is here: https://www.home-assistant.io/integrations/trend/ it can be a bit fiddly to work out what values to use.

      Have you checked how often the Shelly sensor is sending values? If they are too far apart, HA might not be using it in its trend calculations – make sure the sample_duration is greater than the interval between sensor readings.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.