This blueprint is a naive first pass at controlling fans by the change in humidity in a room over time.
Feel free to tweak and edit to your hearts content of course! There’s no way this covers all but a naive scenario, though so far it’s been good enough for me.
Pay close attention to the comments in the YAML, in particular you need to set up a “derivative” sensor for this to work.
# Bathroom Fan Humidity Control # SETUP: # 1) Set up a derivative sensor built up from your humidity data. # You can do this by manually editing your configuration.yaml file with a new "derivative" sensor. # Here is an example, based off of a "sensor.master_bathroom_humidity" sensor that's already set up, and # I'm taking a derivative of the change in humidity over the last 5 minutes. # sensor: # - platform: derivative # source: sensor.master_bathroom_humidity # name: Master Bathroom Humidity Delta # round: 1 # unit_time: min # time_window: "00:05:00" # --- # 2) Add this blueprint to your blueprints. # 3) Choose your new derivative sensor for the "Humidity Derivative Sensor" input. # 4) Choose reasonable values given your environment for how much the humidity has to change over a 5 minute period # (or whatever you set your derivative sensor to) before you start the fan # 5) Choose a value for how long the fan should run based on how long you've observed your fan taking to clear out the # room of moisture after a shower. # 6) Choose the switch for your fan. # 7) Enjoy and tweak, as this first pass is probably not going to be sufficient: but hopefully it serves as a good # starting point for something more sophisticated. blueprint: name: Bathroom Fan Humidity Control description: A first pass at controlling bathroom fans by checking the change in humidity and being able to enter your own guesses for certain thresholds. domain: automation source_url: https://github.com input: humidity_derivative_sensor: name: Humidity Derivative Sensor description: IMPORTANT set up a derivative sensor for your humidity in configuration.yaml and restart before using this! selector: entity: humidity_change_percent_to_start: name: Percent change to start fan description: Over the given period of time, how much % should the humidity have risen to trigger this fan. default: 10 selector: number: min: 1 max: 100 unit_of_measurement: percent fan_switch_target: name: Fan Switch selector: target: entity: domain: switch time_to_run: name: Duration of time to run description: once humidity threshold has been reached, run the fan for this long. Restart the timer if the threshold gets reached again. default: '00:45:00' selector: time: trigger: - platform: numeric_state entity_id: !input humidity_derivative_sensor above: !input humidity_change_percent_to_start below: '100' for: '00:00:01' action: - service: switch.turn_on target: !input fan_switch_target - delay: !input time_to_run - service: switch.turn_off target: !input fan_switch_target mode: restart max_exceeded: silent