Q: Humidity Automation based on Exhaust Fan-Speed

hello community
I am struggling with an humidity automation
in a closed environment with a constant undrpressure, created by an exhaust fan I can control the humidity manually from lovelace with a slider on the % of RPM of the fan, and that workz well when interacting manually

the humidity target to kepp varies automatically depending on the measured temperature
what I do is, I have a formula that calculates the corresponding RH depending on a measured temp, that is target RH
and then with fan-speed I can dial it in manually to be like +/- 0.3 % measured RH vs target RH, so my graph oscillates wich is fine, but th peaks a super low

now I want to automate that
RHtarget < RH measured → too hum → increase fanspeed
when RH target and RH measured are very close or in a certain range, than apply that to fanspeed
and of cause when too low same vice versa

I can raise the RPM on change of measured RH automated, but than when the turning point comes RPM needs to counter that and there I am stuck

this is my current yaml:

alias: Control Exhaust Speed
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.vpd
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition: []
action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.vpd
            below: input_number.vpd_target
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sensor.exhaust_fan
                below: '58'
        sequence:
          - service: fan.increase_speed
            data:
              percentage_step: 1
            target:
              entity_id: fan.exhaust_fan
      - conditions:
          - condition: numeric_state
            entity_id: sensor.vpd
            above: input_number.vpd_target
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sensor.exhaust_fan
                above: '26'
        sequence:
          - service: fan.decrease_speed
            data:
              percentage_step: 1
            target:
              entity_id: fan.exhaust_fan
    default: []
mode: restart

and don’t be confused by all the VPD sensors and input numbers
vpd is vapour pressure deficit and basically nothing else than applying it to humidity values

maybe I shall simplify things ?!

RHt - RH target ( a manually set value and a generally a constant)
RHm - RH measured (value comes every 3 seconds)
FS - fanspeed (% value of max RPM)

best case:
RHt (40%) = RHm (40%) at let’s say fanspeed 50%

now a sample:
. RHT < RHm
. trigger ( any change of RHm )
. action ( fanspeed increased by 1 )
. fanspeed 51
now RHm is still rising
. trigger action fanspeed 52
let’s assume that happens 3x times
by than fanspeed will be at 55 and the measured RHm to make it easy is 5% higher e.g. 45% rRH
now RHm starts dropping by 1 to 44
what happens now is
. RHT < RHm (still more humidity but turnpoint 45 is passed we are one the way down to RHt)
. trigger ( at RHm decrease 45 → 44)
. action fanspeed increased to 56%
. RHm dropping exponentially fast and overshooting RHt

here is the problem in the automation
when the RHm turnpoint is reached, on the way dropping towards RHt the fanspeed should drop too, and maybe even faster than just by 1

all system is on latest versions the time I post this

Home Assistant Core 2022.6.2

Home Assistant Supervisor 2022.05.3

Home Assistant OS 8.0

and if not achievable with homeassitant I have ESPhome running as well and just started to move all my devices from tasmota to ESPhome

Interesting. I have a few questions if you don’t mind.

  1. What is the space you are trying to condition?
  2. You are pulling air from a close environment ? Where is the infiltration air coming from?
  3. Is your goal to reduce the RH?

There may be a reason why you need a very complicated RH control system, but have you tried a Threshold sensor based on Dew Point as the trigger and conditions for the automation?

You can then use the threshold helper attributes to see in, below and above ranges, and adjust fan speeds based on that.

the essential question is how to trigger the turnpoint of a value that constantly oscillates above and below a given target value

hey ya and thx for your input

the area I want to control is a small box with 2 qubic meter
there is actually 3 openings
1 x 150mm exhaust tube to the exhaust fan
2 x 125mm tubes for the intake, one is dragging from indoors, the other from outdoors and both have ‘disk’ shutters in the tube that I can turn by 90° and hence control the opening of the shutters

yes my goal is to reduce the RH with this automation
for the other way - humidifying there id RH low targets nd a fogger automtion that works fine

actually the goal is to keep the RH ‘in sync’ with the temp
temp is measured by bme280 and the value ranges from 20-29°C approx, depending on the environment temp, day / night
this constantly measured temp and a ‘number.input’ helper with a fix given ‘kpa’ value are the base for the formula that calculates based on kpa and temp the target RH
now I have a RHt (target) and the smae bme280 measures RHm
the shutters for the airflow are now secondary in first place, as with these I can marginally influence the temp, so lets say they are set to given positions and temp measured is constant

now the RHm (measured/ actual) needs to be synced to RHt (target)
and than can be easily achieved with the exhaust fan speed as described above … easy, if I do it manually! as when the RHm rises I increase fan-speed in small steps until RHm comes to hld and doesn’t rise anymore, than I lower fan-speed significantly at this RHM turnpoint, and within 2 minutes and 2-3 sinus cycles in the graph I can flatten the curve that much that it oscillates by +/- 0.3% RHm around RHt

hope that explains it better, any info need I will try to provide, just please bare with my english

that is sth that sounds interesting, have no idea yet and dig into docu
but yes … if treshhold is a ‘remember stored value’ than I think that is the right direction

I know it is not going to be easy as this automation shall do actions kind of anticipateing

any further info on your quoted aproach … highly appreciated!
thx

cool would be a kind of flip-flop automation

I think I would try to use a derivative sensor and trigger the fan to speed up or slow down based on how fast and in which direction the rate of change (derivative) of the humidity error is changing.

If the rate of change of the error is positive increase fan speed. If negative lower fan speed until rate of change is ~0.

that sounds exactly what I am looking for
as the process you describe is what I do manually adjusting the slider and in 2-3 sinus curves on the graph around the target I can set it within minutes to be nearly flat

would you mind helping me out
derivative sensor? and what would the trigger look like?
as that is waht I exactly need, kind of anticipating stepsize and direction depending how much OFF the target the RHm is and in wich direction it moves

would really appreciate further help please, my english is not too bad but sometimes I have difficulties finding the right keawords to search for … derivative sensor is my next search :wink: thx

haha that looks quite nice, thx @finity

A PID controller is mostly used to control temperature, but it should also work for humidity:

1 Like

I think I like that even better. I never knew it existed.

Thanks for that info.

If you would still like to stay with the derivative sensor implementation…

in my thinking the trigger should be the derivative sensor value itself.

trigger an automation whenever the derivative sensor value changes:

trigger:
  - platform: state
    entity_id: sensor.your_derivative_sensor
    to: 

then use a “choose:” in the actions to select which way to set the fan.

  • if the absolute value of the to_state of the derivative sensor is higher than the from_state and is positive (error getting bigger in positive direction or humidity still increasing over setpoint) then increase fan speed.

  • if the absolute value of the to_state is lower than from state and still positive (error getting smaller but still above the setpoint) keep fan speed the same since the humidity is going in the right direction.

  • the derivative is 0 then keep the fan speed the same.

  • if the absolute value of the to_state is lower than the from_state and is negative then kep the fan speed the same since it is going in the right direction

  • if the absolute value of the to_state is higher than from_state and is negative (error getting bigger but is now below the setpoint) reduce the fan speed.

the above will require some templating work but I think it should be doable.

1 Like