🚿 Bathroom Humidity Exhaust Fan

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

GitHub Link Click Here

Version: 1.3

The most common automation used for a bathroom humidity exhaust fan.

The Automation Process:

  • When the humidity rises above a set percentage value over a time window the fan will turn ON. You can also turn ON lights.
  • When the humidity falls below a set percentage value over a time window the automation will then wait for the time delay and then turn the fan OFF.
  • You have the option to use the “Fan Speed - Off Switch Option”. Sometimes you need to select a different entity to turn ON for the fan to turn OFF.
  • You have the option to use a By-pass. This allows you to add a switch to manually By-pass the “Humidity Derivative Sensor”.
  • You have two safe guards. The first one is the maximum run time for the fan. The second one is, if Home Assistant restarts.

Note: You must set up a “Derivative Sensor Helper” in HA for this automation to work. See our FAQ on how to set this up correctly. It is quick and easy :slightly_smiling_face:

blueprint:
  name: Bathroom Humidity Exhaust Fan
  description: >
    # Bathroom Humidity Exhaust Fan
    
    **Version: 1.3**


    The most common automation used for a bathroom humidity exhaust fan.


    Let us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/bathroom-humidity-exhaust-fan/509992)


    **The Automation Process:**
     - When the humidity rises above a set percentage value over a time window the fan will turn ON. You can also turn ON lights.
     - When the humidity falls below a set percentage value over a time window the automation will then wait for the time delay and then turn the fan OFF.
     - You have the option to use the "Fan Speed - Off Switch Option". Sometimes you need to select a different entity to turn ON for the fan to turn OFF.
     - You have the option to use a By-pass. This allows you to add a switch to manually By-pass the "Humidity Derivative Sensor".
     - You have two safe guards. The first one is the maximum run time for the fan. The second one is, if Home Assistant restarts.

    Note: You must set up a "Derivative Sensor Helper" for this automation to work. See our FAQ on how to set this up correctly.


    **Need help?** See our FAQ: [Click Here](https://community.home-assistant.io/t/bathroom-humidity-exhaust-fan/509992/2?u=blacky)
  domain: automation
  input:
    trigger:
      name: Humidity Derivative Sensor 
      description: Select your humidity derivative sensor.
      selector:
        entity:
          domain:
            - sensor
    fan_switch:
      name: Fan Switch
      description: Select the fan you would like to turn ON. You can also add lights.
      selector:
        target:
          entity:
            domain:
              - light
              - switch
              - script
    fan_speed_off:
      name: Fan Speed - Off Switch Option (Optional)
      description: Sometimes you need to select a different entity to turn ON for the fan to turn OFF. 
        This is normally used when having a fan that has different speeds.
        Please DO NOT select the same entities that are selected above in "Fan Switch" here, as the automation will not work.
      default: []
      selector:
        entity:
          multiple: true
          domain:
            - switch
            - script
    rising_humidity:
      name: Rising Humidity
      description: Set the percentage the humidity must rise within the derivative sensor time window to turn the fan ON.
      default: 1
      selector:
        number:
          min: 0
          max: 5
          step: 0.1
          unit_of_measurement: '%'
    falling_humidity:
      name: Falling Humidity
      description: Set the percentage the humidity must fall within the derivative sensor time window to turn the fan OFF.
      default: -1
      selector:
        number:
          min: -5
          max: 0
          step: 0.1
          unit_of_measurement: '%'
    time_out:
      name: Safe Guard - Maximum Run Time
      description: Set the safe guard time. If the fan gets turned ON by the automation and the falling humidity fails to execute, then 
        the safe guard will by-pass the falling humidity after its set time and proceed to the time delay.
      default: 20
      selector:
        number:
          min: 5
          max: 60
          step: 0.5
          unit_of_measurement: minutes
    time_delay:
      name: Time Delay
      description: Set the delay time to wait before turning the fan OFF after the falling humidity % has been achieved or the safe guards set time has passed.
      default: 10
      selector:
        number:
          min: 0
          max: 20
          step: 0.5
          unit_of_measurement: minutes
    include_bypass:
      name: Use The Humidity Derivative Sensor By-pass Option (Optional)
      description: Select enable or disable. 
      default: bypass_disabled
      selector:
        select:
          options:
            - label: Enable the By-pass option
              value: "bypass_enabled"
            - label: Disable the By-pass option
              value: "bypass_disabled"
    by_pass:
      name: Humidity Derivative Sensor By-pass
      description: Select a switch that will By-pass the humidity derivative sensor and make your fan function as normal. 
        The entity cannot be included in, "Fan Switch" and or "Fan Speed - Off Switch Option" selections.
      default: []
      selector:
        entity:
    include_ha_restart:
      name: Safe Guard - Use The HA Restart Option (Optional)
      description: If Home Assistant restarts, and the fan is ON, the fan will stay ON until the trigger is triggered again and 
        the automation runs. In this scenario the fan could stay ON for a very long time.
        Enabling this option will allow you to turn the fan OFF in a set time delay, providing a safe guard option.
      default: restart_disabled
      selector:
        select:
          options:
            - label: Enable the HA restart safe guard option
              value: "restart_enabled"
            - label: Disable the HA restart safe guard option
              value: "restart_disabled"
    ha_restart:
      name: Safe Guard - HA Restart Time Delay
      description: Set the delay time to wait before turning the fan OFF if the fan is ON after Home Assistant restarts.
      default: 20
      selector:
        number:
          min: 5
          max: 60
          step: 0.5
          unit_of_measurement: minutes

mode: restart
max_exceeded: silent

variables:
  trigger: !input trigger
  fan_switch: !input fan_switch
  fan_speed_off: !input fan_speed_off
  rising_humidity: !input rising_humidity
  falling_humidity: !input falling_humidity
  time_out: !input time_out
  time_delay: !input time_delay
  include_bypass: !input include_bypass
  by_pass: !input by_pass
  include_ha_restart: !input include_ha_restart
  ha_restart: !input ha_restart

trigger:
  - platform: numeric_state
    id: "t1"
    entity_id: !input trigger
    above: !input rising_humidity
    below: "100"
  - platform: homeassistant
    id: "t2"
    event: start

# All Conditions
condition:

# Check Humidity Derivative Sensor By-pass
  - condition: or
    conditions:
      - "{{ include_bypass == 'bypass_disabled' }}"
      - "{{ by_pass == [] }}"
      - "{{ (include_bypass == 'bypass_enabled') and (states[by_pass].state == 'off') }}"

action:
  - choose:
      - conditions:
          - "{{ (include_ha_restart == 'restart_enabled') and (expand(fan_switch.entity_id) | selectattr('state', '==', 'on') | list | count > 0) or (include_ha_restart == 'restart_enabled') and (expand(fan_switch.entity_id) | selectattr('domain', '==', 'script') | list | count > 0) }}"
          - condition: trigger
            id: 't2'
        sequence:
          - alias: "Wait the number of minutes that has been set for ha restart time delay"
            delay:
              minutes: !input ha_restart
          - alias: "Turn off the fan"
            service: homeassistant.turn_off
            target: !input fan_switch
          - alias: "Fan speed off option"
            service: homeassistant.turn_on
            entity_id: !input fan_speed_off
    default:
      - alias: "Check trigger is t1"
        condition: trigger
        id: 't1'
      - alias: "Turn on the fan"
        service: homeassistant.turn_on
        target: !input fan_switch
      - alias: "Wait until Humidity Derivative Sensor drops"
        wait_for_trigger:
          platform: numeric_state
          entity_id: !input trigger
          below: !input falling_humidity
        timeout:
          minutes: !input time_out
      - alias: "Wait the number of minutes that has been set for the time delay"
        delay:
          minutes: !input time_delay
      - alias: "Turn off the fan"
        service: homeassistant.turn_off
        target: !input fan_switch
      - alias: "Fan speed off option"
        service: homeassistant.turn_on
        entity_id: !input fan_speed_off

CHANGELOG

  • Version: 1.3: - 6 Feb-23 - Added the ability to use scripts.
  • Version: 1.2: - 26 Jan-23 - Added “Fan Speed - Off Switch Option” and ability to select lights.
  • Version: 1.1: - 22 Jan-23 - Added safeguard if Home Assistant restarts
  • Version: 1.0: - 30 Dec-22 - Initial release

MY OTHER BLUEPRINTS
Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time
Smart Relay - Contactor
Push Button Relay - Contactor
Toilet Exhaust Fan with time delay
Timer Relay - Run ON Timer
Entity - Run ON Timer
Temperature Control Exhaust Fan
Temperature Control Exhaust Fan - Inverted
Turn Light, Switch or Scene On & Off with Trigger Conditions

9 Likes

FAQ

Q: How do you set up a Derivative Sensor Helper?

A: Please follow these steps Click Here

Q: I have set up a “Derivative Sensor Helper” but how do i set up the automation settings?

A: Please follow these steps Click Here

Q: How to use the “Humidity Derivative Sensor By-pass” without having a physical switch?

A: Go to Settings / Devices & Services / click on the “Helpers” tab / click “+ CREATE HELPER” and select “Toggle”. In the name put “Bathroom Humidity Sensor By-pass” and click save. Then go back into the automation and in the “Humidity Derivative Sensor By-pass” search for the name you created in this case “Bathroom Humidity Sensor By-pass” and click save. Now in a “Dashboard” click “Edit dashboard” then click “+ ADD CARD” click on “Button” or “Entities” in the entity field again search for the name you created in this case “Bathroom Humidity Sensor By-pass” and click save. Then click “DONE”. You now have a “Humidity Derivative Sensor By-pass” switch to disable the Humidity Derivative Sensor.

Q: I would like to set a different value but the slider is not letting me?

A Just simply type the number value you would like in the field and click save. A red line will appear under the number you have entered but once you click save, exit the automation and go back into it the red line will not be there.

Q: How do you update the blueprint and not delete / recreate existing automations?

A Please follow these steps Click Here

1 Like

Derivative Sensor Helper - FAQ

In order for this automation to work you must set up a Derivative Sensor Helper in HA and you must have a humidity sensor located in the bathroom. In my bathroom I use a Xiaomi LYWSD03MMC temperature & humidity sensor located approximately 220 cm or 7.2 feet above floor level (see below) but any humidity sensor should work.

5

To add derivative sensor helper to HA, follow these steps.

Go to Settings / Devices & Services and click on the “Helpers” tab at the top. Click create helper and select “Derivative”

Fill out the name you would like your derivative sensor to be, select your humidity sensor in “input sensor” (this is my Xiaomi LYWSD03MMC sensor) , precision = 2, time window can be 3 to start but you can change this later (see edit helper below) and in time unit, select “minutes”. Now click “SUBMIT”

Now go back into the blueprint and select / enter that derivative sensor in the “Humidity Derivative Sensor” Fill out the rest of the settings to your requirements.

Your exhaust fan should automatically come ON now when you have a shower and turn OFF when your finished. :wink:

EDIT HELPER
If you need to edit the Helper. Go back to Settings / Devices & Services / click on the “Helpers” tab / click the helper you would like to edit, in this case “Bathroom Humidity Derivative” and then select “Derivative Options”

You will then see your settings. Edit as required.

If you have now set up a “Derivative Sensor Helper” and you would like to know how to set up the automation settings so if functions correctly Click Here

Enjoy

Blacky :grinning:

Back to FAQ: Click Here

2 Likes

Thanks! I have been looking for something like this for some time. None of the methods I have tried have been reliable enough to trust. I’ll see how it works tomorrow morning :slight_smile:

One nice addition would be to add a time out, so that the fan will be turned off after a period of time even if the humidity hasn’t dropped enough.

Already there :blush:

1 Like

@sota no problem at all.

Hope it what your looking for, let us know how you go.

1 Like

The automation did not trigger this morning. The humidity derivative went to a max of +3.8% and -4.5%, but I had set the rising and falling limits to + & -5%. I reduced them to 3.5% and I’ll try again tomorrow.
Two possible suggestions:

  1. I currently trigger the fan when the bathroom light is turned on and turn it off 30 minutes after the light is turned off. It would be nice to have the option to include an entity that would turn on the fan immediately instead of waiting for the humidity to rise.
  2. When trying to get this to work, I had problems with false triggers - usually in the middle of the night. Not good for the WAF as the bathroom is off our bedroom! I don’t know if you have experienced this, but it might be nice to have a lockout time range where the automation cannot trigger.

Thanks.

I would suggests you start at +1 & -1. The best way to find your settings is to add your fan, humidity sensor and your derivative sensor into a dashboard. You will then be able to monitor your site. When you have a shower have a look at what happened and look at the first real increase to see what % that is. Below is a example and this is just normal humidity changes through the day in a 2 hour window.

below is a actual shower. The idea is to have the lowest % possible that will not give you a false trigger. Sensor position should also be considered (close to the steam).

I have a different blueprint for this called 'toilet exhaust fan with time delay"

Is this with this blueprint? as I haven’t had any false triggers to date. I have had false triggers when I tried different blueprints turning ON at night.

Thanks for the tips, I have done that now. I just started with your blueprint yesterday, so I am trying to avoid false triggers while getting it to work :wink: Previously, I had used the Generic Hygrostat integration and it was very unreliable.
Here is the graph from today showing the peaks for the shower around 9:00am, but there are also peaks of +1% and -1.5% so I think I will start at 2% and take it from there.

Screenshot 2023-01-01 171549

Yep that’s the way to do it :+1:

Success! The fan turned on just over a minute after the shower started, and it triggered the off delay about two minutes after it stopped.
Thanks!

1 Like

All good :smiley: :+1:

The Settings - FAQ

First you must set up a “Humidity Derivative Sensor”. On how to do this Click Here

Humidity Derivative Sensor

This is the sensor that will be used as the trigger.

Fan Switch

This is the fan you would like to turn ON. Lights can also be added. It is normal used when you have a niche in the shower that has a LED’s strip lighting and you would like to turn them ON when showering and OFF when finished automaticity.

Fan Speed - Off Switch Option

Sometimes you need to select a different entity to turn the fan OFF. This is normally used when having a fan that has different speeds and one of the speeds is OFF. You normally have to turn ON the switch to turn the fan OFF. If you have this scenario then select your OFF speed entity here. If you do not have this, then please leave it blank.

Rising Humidity & Falling Humidity Settings

Once you have your “Humidity Derivative Sensor” set up in HA the best way to find your settings is to add your exhaust fan, humidity sensor and your humidity derivative sensor into a dashboard. To do this, go into a “Dashboard” then top right 3 dots click “Edit dashboard”, then click “+ ADD CARD”, click on “Entities” in the entity field add your exhaust fan, humidity sensor and your humidity derivative sensor entities, then show “2” hours (you can change this any time), click save & “DONE”. You will now see something like this.

The above image shows humidity changes throughout the day in a 2 hour window. You can see the “Humidity Derivative Sensor” + & - values of around + 0.75 & - 0.48. Yours can be higher as it all depends on your site and the location of your sensor.

The below image is what happens when we have a shower. The image shows 2 showers data. You can see the first shower goes to + 10.0 then when finished around - 7.0. The next shower goes to + 14.0 then when finished around - 7.5. If you move your mouse over your graph in HA a pop up window will show more accurate figures.

Because we can see what is happening, we can now adjust our setting. Looking at the Rising Humidity Derivative %. The first shower jump is just below + 5.0 and the ending is just above -5.0. The second shower first jump is around + 7.0 and the ending is just above -5.0. Note: These reading are with a working exhaust fan so you may need to set + 1.0 & - 1.0 first then adjust and readjust your settings to get it right.

I have upgraded my sensor and it is now at the highest point right next to the fan inlet so my reading are high. Your reading could be lower but the working principle is the same.

I have monitored my site for some time now and I know my readings during the day never go above + 2.3 & - 1.5. Having the sensor up high next to the fan always has a similar results when showering as the above graph. It is good to keep your setting a low as possible as it will react faster but at the same time we don’t want to have false trigger turning ON the fan all the time, especially at night. I have set my “Rising Humidity %” to + 3.0 & “Falling Humidity %” to - 3.1. Your setting will depend on your site, where you live and your climate but being able to monitor your settings will help you work it out. If you get false trigger turning ON the fan consider raising your + value as this is what turns your fan ON. The - value is what triggers the automation to start the “Time Delay”. Then just monitor what happens and adjust as necessary.

Safe Guard - Maximum Run Time Setting

Think of the longest shower anyone will have and add some time. It is really a safe guard and should never really be needed if your settings are correct. I have set mine to 25 min.

Time Delay

This is important. It really depends on the fan you have, location of your humidity sensor, etc. It is a good idea to monitor it so the fan brings down the humidity before turning it OFF. See the above image how the humidity returns to around the starting value after a shower. Then just monitor what happens and adjust as necessary. Try starting with 10 min and adjust as necessary. I have my “Time Delay” set to 3.5 min.

Humidity Derivative Sensor By-pass

This will allow you to By-pass the humidity derivative sensor and make your fan function as normal. The entity cannot be included in the “Fan Switch” and or “Fan Speed - Off Switch Option” selection. Please see our FAQ on how to set this up without having a physical switch.

Safe Guard - Use The HA Restart Option

If Home Assistant restarts for any reason, and the fan is ON, the fan will stay ON until the trigger is triggered again and the automation runs. In this scenario the fan could stay ON for a very long time. Enabling this option will allow you to turn the fan OFF in a set time delay, providing a safe guard option. I decided if someone just started in the shower and the fan was ON. If I restarted Home Assistant (HA) for any reason at that time, then for us the normal maximum fan time when someone had a shower was around 10 min, so I have set my “HA Restart Time Delay” to 10 min. Then no one would know anything happened, it would look like a normal shower took place if I restart HA.

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

Hello I’m trying to use your blueprint, so far seems the most well thought that I have found for humidity control. I plan to use it in a technical room where I have some electronic equipment (router, switches, etc) but which is also prone to increased level of humidity. I have purchased an Aqara temperature humidity sensor and an Aqara smart plug, I also already have a dehumidifier. So basically what I am trying o do is whenever humidity is rising above a certain procent the dehumidifier to start automatically, it’s on auto and plugged into the Aqara plug. I have created the derivative humidity sensor with the helper and also make the Aqara plug look like a fan switch but in the blueprint settings it says at the fan section that no matching device is found, I have attached the part of the blueprint with the troubling settings.

@ionutm80 Firstly welcome to the community :smiley:

This issue is a bug in the latest release of HA. If you go back to your backup then it will be resolved until HA fixes it but you will loose what you have done from your update to now.

Another way if you are keen then you can try this.

Find out your “entity ID” you would like to use. Go to, Settings / Devices & Services, click on top tab “Entities”. Find it there.

Open the blueprint, click on 3 dots top right, and “edit in YAML”. You should see something like this.

alias: Bathroom Humidity Exhaust Fan
description: ""
use_blueprint:
  path: Blackshome/bathroom-humidity-exhaust-fan.yaml

For “Fan Switch *” enter “input” and change your entity_id to your sensor.

alias: Bathroom Humidity Exhaust Fan
description: ""
use_blueprint:
  path: Blackshome/bathroom-humidity-exhaust-fan.yaml
  input:
    fan_switch:
      entity_id:
        - switch.your_sensor_here

This is how my one looks like once everything is filled in.

alias: Bathroom Humidity Exhaust Fan
description: ""
use_blueprint:
  path: Blackshome/bathroom-humidity-exhaust-fan.yaml
  input:
    trigger: sensor.bathroom_humidity_derivative
    fan_switch:
      entity_id: switch.bathroom_exhaust_fan
    falling_humidity: -2
    rising_humidity: 2
    time_out: 25
    include_bypass: bypass_disabled
    time_delay: 3

Now click 3 dots top right and select “Edit in visual editor”

Hopefully you see your fan now :crossed_fingers:

Fill out the rest.

Not sure if it will work because I don’t know what HA did but be assured the blueprint works.

1 Like

Hi again, it worked, I could add my fan switch, now I have to fine tune the automation based on your guidance above. Thanks a lot for this blueprint and for the help provided!

Love it. If you have any other questions just ask. Your use case is interesting.

1 Like

Hi again,

I have set the derivative sensor with a time window of 3 minutes as per your FAQ above. Initially I have set the autommation based on your blueprint to -0.5 & 0.5 so it did not triggered when the first event that I was looking for happened: my wife put some clothes to dry in the technical room to take advantage of the heat inside at exactly 9.31 PM, I have attached 2 graphs with the evolution of the 2 sensors.



What would be the best settings for me to trigger specifically when these type of events occur? The derrivative jumps immediately at 9.31 PM but then drops also abruptly at 9.53 PM while the humidity remains high and above the 25% threshold that I would like to see constant within the technical room. Please help me, I’m a bit lost.
Thanks in advance and kind regards.

Hi, I have attached below the evolution up to this morning of the 2 senzors, derivative and actual humidity, as can be seen the derivative is decreasing very abruptly because it has a 3 minute moving average while the actual humidity is decreasing over a longer time period.The small period in which the dehumidifier worked is because I trigerred it manually to see whether the switch is working.

By the way the graphs are before updating this morning to 2023.1.2, after that the derivative senzors do not show anymore like line graphs but instead like history bar.

@ionutm80 I will PM you.