Hi – I have a whole home humidifier and live in an area where temps can range wildly. I’d like to be able to control my ecobee target humidity (which in turn controls the humidifier) based on relative humidity and outdoor temperatures.
Optimal humidity based on outdoor temp:
Template sensor to set target humidity –
The basic calculation works, however, I’d like to set a minimum value of 20% and maximum value of 50% and can’t figure out how to do it, something in my template is off so its showing multiple values.
Example, right now its -15f outside (Northern United States) … which is below (18%) my minimum value (20%) so the template should set it to 20%.
The idea is to setup an automation that runs every 30 minutes to set the thermostat target humidity using this template value. Thanks!
- platform: template
sensors:
outside_temp_humidity_target:
unique_id: 1acb4422-a19f-4618-b2ff-036a02afb7ed
friendly_name: Outside Temp Humidity Target
unit_of_measurement: "%"
device_class: humidity
value_template: >
{% set humidity_min = 20 | float %}
{% set humidity_max = 50 | float %}
{% set t = states('sensor.pirateweather_temperature') | float %} {{ ((t / 2) + 25) | round|int }}
{% if (t > humidity_min | float) and (t < humidity_max | float) %}
{{ t }}
{% else %}
{{ humidity_min }}
{% endif %}