Having had some troubles finding existing examples online, I thought to share my configuration.yaml to compute dew point/temperature according to the Arden Buck Equation.
According to Dew point - Wikipedia this equation provides high accuracy.
I verified my code against this online dew point calculator (Dew Point Calculator) and they do match. Pls note, sensor.temperature_X and sensor.humidtiy_Y should be ideally entities of the same device (e.g. Aquara Temperature/Humidity sensor) or they have to belong to devices located in the same room/zone.
sensor:
- platform: template
sensors:
temp_dew_XY:
value_template: >-
{% set T, RH = states('sensor.temperature_X'), states('sensor.humidity_Y') %}
{% if not (T == 'unknown') or (RH == 'unknown') %}
'unknown'
{%- else %}
{% set T = T | float %}
{% set RH = RH | float %}
{% set a = 6.1121 | float %}
{% set b = 18.678 | float %}
{% set c = 257.14 | float %}
{% set d = 234.5 | float %}
{% set e = 2.71828 | float %}
{% set P = a*e**((b-T/d)*(T/(c+T))) | float %}
{% set gamma = log((RH / 100)*e**((b-T/d)*(T/(c+T)))) | float %}
{% set dew_temp = ((c * gamma) / (b - gamma))|round(3) %}
{{ dew_temp}}
{% endif %}
unit_of_measurement: "°C"
friendly_name: "Dew Temperature"
Please, let me know in case of comments/questions/suggestions for improvements!
I liked this, but needed dew point calculations for various rooms. Turns out, the new macros syntax is pretty neat to make multiple template sensors with a macro function.
Here’s how it works on my side.
Step 1: Create a new folder custom_templates/ in your configuration folder, if it doesn’t exist already.
Step 2: Create a new file custom_templates/macros.jinja:
{% macro calculate_dew_point(entity_temperature, entity_humidity) %}
{% set T, RH = states(entity_temperature), states(entity_humidity) %}
{% if (T == 'unknown') or (RH == 'unknown') %}
unknown
{% elif (T == 'unavailable') or (RH == 'unavailable') %}
unavailable
{% else %}
{% set T = T | float %}
{% set RH = RH | float %}
{% set a = 6.1121 | float %}
{% set b = 18.678 | float %}
{% set c = 257.14 | float %}
{% set d = 234.5 | float %}
{% set e = 2.71828 | float %}
{% set gamma = log((RH/100)*e**((b-T/d)*(T/(c+T)))) | float %}
{% set dew_point = ((c * gamma) / (b - gamma)) | round(1) %}
{{ dew_point }}
{% endif %}
{% endmacro %}
Just found your post. Worked a treat. Thanks. Just what i was looking to do.
AKE40 - Follow Hzz’s steps.
Use file editor to create the folder and file
Alter template instructions to add and check your sensor variables in developer tools / templates
Then copy the data into a create sensor template helper.
The State part is the most important
Mine was…note only change is sensor names.
For other rooms - other sensor names
NEW SENSOR CONFIGURATION
I used the right click and Generate UUID At Cursor function in Studio Code Server to create new unique_id:'s
NOTE: this is under template: now not sensor: as previous configuation.
I noticed some amazing discussions here around creating dew point calculations using code and custom setups. While those approaches are incredibly powerful and flexible, I wanted to share a simpler alternative for anyone looking to avoid coding and templates.
I’ve recently uploaded a Dew Point Integration for Home Assistant to GitHub. It’s available to install via HACS as a custom repertory, and everything is configured through the UI, so no YAML or custom template code is needed.
The integration calculates the dew point temperature using the Arden Buck equation, ensuring accurate results. It also supports multiple locations – you can easily create dew point sensors for different areas by adding more sensors via the UI.
If this sounds like something that could simplify your setup, feel free to check it out:
Of course, the template-based solutions are still fantastic for more advanced use cases, but if you’re looking for a plug-and-play option, this might be helpful.
I just installed it and it matches exactly what the above template is giving me. Even though the Arden Buck equation seems to be taking in more variables. ***Correction I am using the Arden Buck equation in the equation I used from this post, excluding the P.
Very easy to use and install.
It seems you can only load one dewpoint sensor, are you able to create multiple dew point sensors?