Last active
December 16, 2021 20:25
-
-
Save JohnNeville/8959067c7ff6b70274fe6fff12b54cd1 to your computer and use it in GitHub Desktop.
Switch a fan based on absolute humidity difference between two humid/temp sensors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(Primary) | |
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(Primary) | |
description: A sensor that measures the temperature of the area to be vented, for examle the shower | |
selector: | |
entity: | |
domain: sensor | |
humidity_sensor2: | |
name: Humidity Sensor(Secondary) | |
description: A second sensor that measures the humidity of the area to be vented, for example the shower. Either device can trigger the integration and both must fall below a threshold to turn off the vent. | |
selector: | |
entity: | |
domain: sensor | |
temperature_sensor2: | |
name: Temperature Sensor(Secondary) | |
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_light: | |
name: Fan Light | |
description: A light domain switch that turns the fan on and off | |
selector: | |
entity: | |
domain: light | |
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: 5.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: 6.0 | |
mode: slider | |
step: 0.1 | |
default: 0.9 | |
min_triggering_humidity: | |
name: Minimum Humidity | |
description: The minimum registered sensor humidity that will trigger the switch to be turned on | |
selector: | |
number: | |
min: 40.0 | |
max: 70.0 | |
mode: slider | |
step: 2.0 | |
default: 60.0 | |
trigger: | |
- entity_id: !input "humidity_sensor" | |
platform: state | |
- entity_id: !input "humidity_sensor2" | |
platform: state | |
- entity_id: !input "reference_humidity_sensor" | |
platform: state | |
condition: | |
- condition: template | |
value_template: "{{ mode != light_state }}" | |
action: | |
- service: light.turn_{{mode}} | |
entity_id: !input "fan_light" | |
variables: | |
temperature_sensor: !input "temperature_sensor" | |
humidity_sensor: !input "humidity_sensor" | |
temperature_sensor2: !input "temperature_sensor2" | |
humidity_sensor2: !input "humidity_sensor2" | |
reference_temperature_sensor: !input "reference_temperature_sensor" | |
reference_humidity_sensor: !input "reference_humidity_sensor" | |
fan_light: !input "fan_light" | |
light_state: "{{ states(fan_light) }}" | |
rising_threshold: !input "rising_threshold" | |
falling_threshold: !input "falling_threshold" | |
min_triggering_humidity: !input "min_triggering_humidity" | |
humidity_state: "{{ states(humidity_sensor) }}" | |
humidity2_state: "{{ states(humidity_sensor2) }}" | |
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 %} | |
abs_humid2: >- | |
{% set h, t = states(humidity_sensor2)|float, states(temperature_sensor2) %} | |
{% 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 }}" | |
difference2: "{{ abs_humid2|float - abs_humid_ref|float }}" | |
below_triggering_humidity: "{{ humidity_state|float < min_triggering_humidity|float and humidity2_state|float < min_triggering_humidity|float }}" | |
above_rising_threshold: "{{ difference|float > rising_threshold|float or difference2 > rising_threshold|float }}" | |
above_falling_threshold: "{{ difference|float > falling_threshold|float or difference2 > falling_threshold|float }}" | |
mode: | |
"{%below_triggering_humidity|boolean | |
%}off{% elif light_state == 'off' and above_rising_threshold|boolean | |
%}on{% elif light_state == 'on' and above_falling_threshold|boolean | |
%}on{% else %}off{% endif %}" | |
mode: single |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment