Ventilation: dynamic output related to humidity

Hi there,

since it’s possible to control my ventilation on percentage it’s time to optimize my home-ventilation.
I hope that you can help me forward with to topics:

  • Currently the output of the Fan is static: if hum > X then output fan is Y. I would like to change that in a dynamic solution: if hum > 70, then output Fan is eg. 50 + 0,5 humidity (sensor.badkamer_2)
  • In my current config the fan wil be activated at a fixed setpoint (73% hum). I would like to relate this point to another sensor (sensor.woonkamer) to prevent that the fan will be activated to to weather conditions outside the bathroom.

I hope that you understand these challenges and can help me with nice solutions.

My current (flawless working :)) configuration

#HOME VENTILATION##
- alias: Badkamer ventilatie
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.badkamer_2
  - platform: state
    entity_id: binary_sensor.toilet
    to: 'on'
  action:
  - service: fan.turn_on
    entity_id: fan.mechanische_ventilatie
  - service: fan.set_percentage
    entity_id: fan.mechanische_ventilatie
    data_template:
      speed: >
        {% set hum = trigger.to_state.state | float %}
        {% if hum < 73 and is_state('binary_sensor.toilet', 'off') %} off ##the 73 should be replaced by sensor.woonkamer + 5##
        {% elif hum < 73 and is_state('binary_sensor.toilet', 'on') %} 60 ##The 60 should be (50+ 0.5*sensor.badkamer_2)##
        {% elif hum < 80 and is_state('binary_sensor.toilet', 'on') %} 60
        {% elif hum < 80 and is_state('binary_sensor.toilet', 'off') %} 30
        {% elif hum < 95 or is_state('binary_sensor.toilet', 'on') %} 90
        {% else %} 90
        {% endif %}

I hope you could guide me in the good direction.

Kind regards,

Pieter

1 Like

What have you tried? It seems like you’re asking for people to code this for you when you already have the solution in your comments. Have you tried replacing them with the code you have in your comments? You have examples right in front of you for getting the state out and the math is simply using a plus sign.

Hi Petro,

the code below is without the modifications I’m struggling with, so without solution.
I’ve put some comments in the code, but don’t know to translate these in a proper code…

1 Like