Basement fan with dewpoint control, feedback welcome

Basically my fan should run in certain conditions and blow air into the basement to lower the humidity in my basement (dew point relationship inside vs outside). This flowchart depicts the logic.

Fan runs …

  • only if basement humidity is above a certain threshold
  • only if basement temp is above a certain threshold
  • only during the night (say 22:00 - 07:00)
  • only if dewpoint difference is above a certain threshold
  • max 5 times: blow air for 45min, wait 30min, repeat.

Counter is reset at noon (so the “set index to 0” is a bit misleading).

Key challenge was to avoid an automation prone to HA restarts or reloading of automations (hence I used timers).

My question is: how do I start the next run of the fan (right now, once the wait is over, I simply get a notify.persistent_notification). Can automations trigger themselves (and evaluate that with a certain trigger_id)?

Any feedback welcome.

alias: Basement fan control with dewpoint
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.dew_delta_ok
    from: 'False'
    to: 'True'
    id: ready2startfan
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.dewtimer_runfan
    id: runfanfinished
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.dewtimer_pausefan
    id: pausefanfinished
  - platform: time_pattern
    hours: '12'
    minutes: '00'
    seconds: '00'
    id: noon
  - platform: homeassistant
    event: start
    id: hastart
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - ready2startfan
              - hastart
          - condition: state
            entity_id: sensor.dew_delta_ok
            state: 'True'
          - condition: state
            entity_id: sensor.dew_humidity_ok
            state: 'True'
          - condition: state
            entity_id: sensor.dew_temp_ok
            state: 'True'
          - condition: state
            entity_id: sensor.dew_timewindow_ok
            state: 'True'
          - condition: numeric_state
            entity_id: counter.dew_index
            below: '5'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.shellys_keller_luefter1
          - service: timer.start
            data: {}
            target:
              entity_id: timer.dewtimer_runfan
          - service: counter.increment
            data: {}
            target:
              entity_id: counter.dew_index
      - conditions:
          - condition: trigger
            id: runfanfinished
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.shellys_keller_luefter1
          - service: timer.start
            data: {}
            target:
              entity_id: timer.dewtimer_pausefan
      - conditions:
          - condition: trigger
            id: pausefanfinished
        sequence:
          - service: notify.persistent_notification
            data:
              message: fan finished once
      - conditions:
          - condition: trigger
            id: noon
        sequence:
          - service: counter.reset
            data: {}
            target:
              entity_id: counter.dew_index
    default: []
mode: single

Since the sole purpose is humidity control, can you drive the automation based on it, and an off time?

The conditions you have defined are fairly specific and I am wondering if you could simplify them a little bit? I am building something very similar at the moment, and the way I am approaching this is:

  • Define a target (maximum) runtime for the fan per day in minutes.
  • Have a sensor that measure how long the fan has been running already per day.
  • Define automations as follows:
    • Automation 1:
      • Trigger 1: Dewpoint difference is above fixed threshold.
      • Trigger 2: Fixed time, for example 6am
      • Condition 1: Evaluate if current time is between 6am and 6pm (I want to run my fan during the day).
      • Condition 2: Dewpoint difference is above fixed threshold.
      • Condition 3: Evaluate if fan runtime is less than target runtime.
      • Action: Turn on fan
    • Automation 2:
      • Trigger 1: Dewpoint difference is below fixed threshold
      • Trigger 2: Fan runtime equal or larger than target runtime
      • Trigger 3: Fixed time, for example 6pm
      • Action: Turn off fan
  • To avoid a situation where the dewpoint difference is oscillating around the on/off point, and thus the fan would constantly turn on and off, I am planning to define a template binary sensor that turns on and off with a delay (for example 10 minutes). And then this binary sensor would be used in the triggers above.
  • In addition to the above I would define a toggle helper to control if the fan should be automated or not - just in case I wanted to manually turn the fan on and off in special circumstances.

With these types of automations you avoid that something goes wrong when HA isn’t running for a while. And in general for this use-case it is probably acceptable if in rare occasions the fan runs a little longer or a little shorter per day.

Thanks for the hints. However, most commercial appliances cycle (i.e. fans blow, pause, repeat). While the fans pause, the air in the basement can take up water again. If your fans blow the whole time you will not be able to benefit from this effect.

In the meantime, I have finished the automation. Once the timer from the pause has finished it fires and event. That event again triggers the automation.

alias: Basement fan control with dewpoint
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.dew_delta_ok
    from: 'False'
    to: 'True'
    id: dewdeltaok
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.dewtimer_runfan
    id: runfanfinished
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.dewtimer_pausefan
    id: pausefanfinished
  - platform: time_pattern
    hours: '12'
    minutes: '00'
    seconds: '00'
    id: noon
  - platform: homeassistant
    event: start
    id: hastart
  - platform: event
    event_type: dew_event
    event_data:
      foo: bar
    id: waitfinished
  - platform: state
    entity_id:
      - binary_sensor.dew_timeframe
    to: 'off'
    id: timeframeend
  - platform: state
    entity_id:
      - binary_sensor.dew_timeframe
    to: 'on'
    id: timeframebegin
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - timeframebegin
              - dewdeltaok
              - hastart
              - waitfinished
          - condition: state
            entity_id: sensor.dew_delta_ok
            state: 'True'
          - condition: state
            entity_id: sensor.dew_humidity_ok
            state: 'True'
          - condition: state
            entity_id: sensor.dew_temp_ok
            state: 'True'
          - condition: state
            entity_id: binary_sensor.dew_timeframe
            state: 'on'
          - condition: numeric_state
            entity_id: counter.dew_index
            below: '5'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.shellys_keller_luefter1
          - service: timer.start
            data:
              duration: '{{states(''input_number.dew_duration_fan'')|int*60}}'
            target:
              entity_id: timer.dewtimer_runfan
          - service: counter.increment
            data: {}
            target:
              entity_id: counter.dew_index
      - conditions:
          - condition: trigger
            id: runfanfinished
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.shellys_keller_luefter1
          - service: timer.start
            data:
              duration: '{{states(''input_number.dew_fan_wait'')|int*60}}'
            target:
              entity_id: timer.dewtimer_pausefan
      - conditions:
          - condition: trigger
            id: pausefanfinished
        sequence:
          - service: notify.persistent_notification
            data:
              message: Fan finished run {{ states('counter.dew_index') }}
          - event: dew_event
            event_data:
              foo: bar
      - conditions:
          - condition: trigger
            id: noon
        sequence:
          - service: counter.reset
            data: {}
            target:
              entity_id: counter.dew_index
      - conditions:
          - condition: trigger
            id: timeframeend
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.shellys_keller_luefter1
          - service: timer.cancel
            data: {}
            target:
              entity_id:
                - timer.dewtimer_pausefan
                - timer.dewtimer_runfan
    default:
      - service: notify.persistent_notification
        data:
          title: Fan control basement
          message: ' delta_ok {{states(''sensor.dew_delta_ok'')}} {{''\n''-}} hum_ok {{states(''sensor.dew_humidity_ok'')}} {{''\n''-}}temp_ok {{states(''sensor.dew_temp_ok'')}} {{''\n''-}}time_ok {{states(''binary_sensor.dew_timeframe'')}} {{''\n''-}}index {{states(''counter.dew_index'')}}'
mode: queued

The automation itself needs a bunch of helper variables and sensors.

29.05.2022: edited as binary sensors are on/off and not true/false.

1 Like

Hi, this has been extensively discussed before. :wink:

I myself used a trend-sensor for outside-dewpoint. If dewpoint is falling and bellow inside dewpoint, I switch the fan on. And I added a delay to stop the fan from ‘flickering’, if trend-value jumps around 0.

Trend - Home Assistant

1 Like

Can you share your working solution, please?

In the meantime I have fine-tuned my subfloor ventilation system further, also thanks to the great inputs in this thread. Check out my write up if you are interested in this topic:

2 Likes