Skip to content

Instantly share code, notes, and snippets.

@revin34
Last active February 7, 2022 20:35
Show Gist options
  • Save revin34/132480c31109904733a15f8b2f68170d to your computer and use it in GitHub Desktop.
Save revin34/132480c31109904733a15f8b2f68170d to your computer and use it in GitHub Desktop.
# Dumb way to control humidity in Bathroom using mechanical ventillation fan.
# It tries to be quiet and enable fan after people leave the room, except it is really necessary.
# Fan is usually turned on in periods when light is off.
# original version:
# https://github.com/KrzysztofHajdamowicz/home-assistant-blueprints/
blueprint:
name: Humidity controller
description: Turn on and turn off your fan according to humidity and (assumed) user presence.
domain: automation
source_url: https://github.com/KrzysztofHajdamowicz/home-assistant-blueprints/raw/main/humidity_controller.yaml
input:
humidity_sensor:
name: Humidity sensor
selector:
entity:
domain: sensor
device_class: humidity
light:
name: Light (or light group) to influence turning on or off fan.
selector:
entity:
domain: light
fan:
name: Fan to turn on or off depending on humidity sensor
selector:
entity:
domain: switch
high_humidity_level:
name: High humidity level
description: Turn on the fan, when humidity is above this value, but light is turned off.
default: 60
selector:
number:
min: 40
max: 100
unit_of_measurement: '%'
low_humidity_level:
name: Low humidity level
description: Turn off the fan, when humidity is below this value.
default: 55
selector:
number:
min: 40
max: 100
unit_of_measurement: '%'
extreme_humidity_level:
name: Extreme humidity level
description: Turn of the fan above this level and don't watch for light status!
default: 70
selector:
number:
min: 40
max: 100
unit_of_measurement: '%'
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input humidity_sensor
id: humidity
- platform: state
entity_id: !input light
id: presence
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: !input light
state: 'off'
- condition: numeric_state
entity_id: !input humidity_sensor
above: !input high_humidity_level
sequence:
- service: switch.turn_on
target:
entity_id: !input fan
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input light
state: 'on'
- condition: numeric_state
entity_id: !input humidity_sensor
below: !input low_humidity_level
sequence:
- service: switch.turn_off
target:
entity_id: !input fan
- conditions:
- condition: numeric_state
entity_id: !input humidity_sensor
above: !input extreme_humidity_level
sequence:
- service: switch.turn_on
target:
entity_id: !input fan
default: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment