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.
This blueprint also contains an input switch (for example the Light) which, if on, blocks the automatically start of the fan.
blueprint without the light switch: Switch a fan based on absolute humidity differnece between two humid/temp sensors
Requirements:
- switch for the fan
- switch for the light
- temperature
- humidity
- reference temperature
- reference humidity
blueprint:
name: Humidity Management based on abs. humidity (g/m3); With blocking LightSwitch
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
selector:
entity:
domain: sensor
temperature_sensor:
name: Temperature Sensor
description: A sensor that measures the temperature of the area
selector:
entity:
domain: sensor
reference_humidity_sensor:
name: Reference Humidity Sensor
description: A sensor that indicates the baseline humidity of the location
selector:
entity:
domain: sensor
default: []
reference_temperature_sensor:
name: Reference Temperature Sensor
description: A sensor that indicates the baseline temperature of the location
selector:
entity:
domain: sensor
default: []
fan_switch:
name: Fan Switch
description: A switch that turns the fan on and off
selector:
entity:
domain: switch
light_switch:
name: Light Switch
description: A switch that turns the light on and off. If provided,
the fan will be stopped and not turned on if the light is on.
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"
light_switch: !input "light_switch"
switch_state: "{{ states(fan_switch) }}"
block_state: "{{ states(light_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 and block_state =='off'
%}on{% elif switch_state == 'on' and difference|float > falling_threshold|float and block_state =='off'
%}on{% else %}off{% endif %}"
mode: single