Automating Bathroom Exhaust Fan

I just installed a smart switch for the bathroom exhaust fan, as well as have a zigbee temp/humidity sensor in the bathroom, so as far as hardware, I’m ready to go. I am not sure how to do the automation, though. I know I could easily do on/off setpoints for humidity, but the humidity in the house varies a little bit depending on the weather or the season.

I think what I’d like to happen is when we manually turn on the fan, it stores the current humidity in a variable, and then the fan runs until it returns to the value when it started. Is this something that can be done in Home Assistant, though? Are there any other better ways to automate an exhaust fan

I’m learning!

I am now able to store the humidity pre condition in sensor.bathroom_humidity_pre_state

I’m having trouble, though, using that in a trigger. What I want, in English, is:

(sensor.bathroom_humidity) < ((sensor.bathroom_humidity_pre_state) + 5)

I haven’t used value templates before, and everything I’m trying isn’t working. Any suggestions on what the correct trigger would be?



I have a very simple automation to turn on a fan.
I am working on a much more complicated one that involves dew point and air quality.

alias: Laundry Fan Humid On
description: Run Fan when Humid in Laundry Room
  - above: 60
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    domain: sensor
    entity_id: sensor.aeon_labs_zw100_multisensor_6_relative_humidity
    platform: device
    type: value
condition: []
  - device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    domain: switch
    entity_id: switch.shelly_shsw_pm_xxxxxxxxxxxx
    type: turn_on
mode: single

Is there really a need to include this into your smart-home setup?

What I did, I purchased switches with built-in humidity sensor. They do kick in whenever there is too much humidity in the bathroom. Simple, not too smart, and self-contained… unless you want to track how often it kicks in, the humidity at any given time, and the like.

Here is the one I got, and it comes in two versions: humidity/fan only or with light. There is a setting also to adjust sensitivity, though I simply set mine in the mid-range.

Hi. Look at trend sensor and derivative sensors in the documentation.

This is the point: Humidity measures are relative.
If you simply measure a threshold value from the sensor, you will have false senses. Depending on the weather, it will start your fan and never stop until the natural humidity outside is below the threshold.

To overcome this, you can use 2 sensors instead; one outside the bathroom that mesures the base humidity and one that measures the actual humidity in the bathroom: calculate the delta between them and switch on when is is above a range. Switch it off when a target offset is reached or a timeout has passed.

Alternative, you can create a variable using this a variable component and store the humidity value every minute unless the delta threshold is meet. Use that as the refence value. calculate the delta between the reference and the actual sensor and switch on when is is above a range. Switch it off when a target offset is reached or a timeout has passed.