Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbigras/632779454f874e185632a68164c483e1 to your computer and use it in GitHub Desktop.
Save bbigras/632779454f874e185632a68164c483e1 to your computer and use it in GitHub Desktop.
bathroom-humidity-exhaust-fan.yaml
blueprint:
name: Bathroom Humidity Exhaust Fan
description: >
# Bathroom Humidity Exhaust Fan
**Version: 1.1**
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.
- 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 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.
selector:
target:
entity:
domain:
- switch
- light
include_bypass:
name: Use The Humidity Derivative Sensor By-pass Option (Optional)
description: Select enable or disable.
default: none
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 the fan switch.
default: none
selector:
entity:
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_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
include_bypass: !input include_bypass
by_pass: !input by_pass
rising_humidity: !input rising_humidity
falling_humidity: !input falling_humidity
time_out: !input time_out
time_delay: !input time_delay
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 == 'none' }}"
- "{{ include_bypass == 'bypass_disabled' }}"
- "{{ by_pass == 'none' }}"
- "{{ (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) }}"
- 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: light.turn_off
target: !input fan_switch
default:
- alias: "Check trigger is t1"
condition: trigger
id: 't1'
- alias: "Turn on the fan"
service: light.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: light.turn_off
target: !input fan_switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment