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.
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)?
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.
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.
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: