Description
If switching a fan based on the relative humidity difference between two rooms, if there is a temperature difference, the rule does not provide a consistent behavior. Therefor it is needed to calculate the absolute humidity in g/m3 based on the temperature and relative humidity.
Based on the blueprint of ride4sun (sorry for the missing Link, new users can only post two links…)
Requirements:
- switch for the fan
- temperature
- humidity
- reference temperature
- reference humidity
Blueprint with an additional light switch which blocks the fan if the light is on: Switch a fan based on absolute humidity difference between two humid/temp sensors, with blocking Light Switch
blueprint:
name: Humidity Management based on abs. humidity (g/m3)
description:
Turn a fan on and off based on the difference between a humidity sensor
and a baseline, based on absolute humidity
domain: automation
input:
humidity_sensor:
name: Humidity Sensor
description: A sensor that measures the humidity of the area to be vented, for example the shower
selector:
entity:
domain: sensor
temperature_sensor:
name: Temperature Sensor
description: A sensor that measures the temperature of the area to be vented, for examle the shower
selector:
entity:
domain: sensor
reference_humidity_sensor:
name: Reference Humidity Sensor
description: A sensor that indicates the baseline humidity of the area outside of the vented, for example the walkway outside the shower
selector:
entity:
domain: sensor
default: []
reference_temperature_sensor:
name: Reference Temperature Sensor
description: A sensor that indicates the baseline temperature of the area outside of the vented, for example the walkway outside the shower
selector:
entity:
domain: sensor
default: []
fan_switch:
name: Fan Switch
description: A switch that turns the fan on and off
selector:
entity:
domain: switch
rising_threshold:
name: Rising Threshold (in g/m3)
description: How many gram/m3 above the reference humidity the sensor
can rise before the fan is turned on
selector:
number:
min: 0.0
max: 3.0
mode: slider
step: 0.1
default: 1.1
falling_threshold:
name: Falling Threshold
description: How many gram/m3 above the reference humidity the sensor
must fall to before the fan is turned off
selector:
number:
min: 0.0
max: 3.0
mode: slider
step: 0.1
default: 0.9
#source_url: https://community.home-assistant.io/t/turn-a-fan-on-and-off-based-on-the-difference-between-a-humidity-sensor-and-a-baseline/255999
trigger:
- entity_id: !input "humidity_sensor"
platform: state
- entity_id: !input "reference_humidity_sensor"
platform: state
condition:
- condition: template
value_template: "{{ mode != switch_state }}"
action:
- service: switch.turn_{{mode}}
entity_id: !input "fan_switch"
variables:
temperature_sensor: !input "temperature_sensor"
humidity_sensor: !input "humidity_sensor"
reference_temperature_sensor: !input "reference_temperature_sensor"
reference_humidity_sensor: !input "reference_humidity_sensor"
fan_switch: !input "fan_switch"
switch_state: "{{ states(fan_switch) }}"
rising_threshold: !input "rising_threshold"
falling_threshold: !input "falling_threshold"
abs_humid_ref: >-
{% set h, t = states(reference_humidity_sensor)|float, states(reference_temperature_sensor) %}
{% if not h or t == 'unknown' -%}
'unknown'
{%- else %}
{% set t = t | float %}
{{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(2) }}
{% endif %}
abs_humid: >-
{% set h, t = states(humidity_sensor)|float, states(temperature_sensor) %}
{% if not h or t == 'unknown' -%}
'unknown'
{%- else %}
{% set t = t | float %}
{{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(2) }}
{% endif %}
difference: "{{ abs_humid|float - abs_humid_ref|float }}"
mode:
"{% if switch_state == 'off' and difference|float > rising_threshold|float
%}on{% elif switch_state == 'on' and difference|float > falling_threshold|float
%}on{% else %}off{% endif %}"
mode: single