If someone is still looking for a working template to calculate the absolute humidity very accurately, here is my template that I created based on this calculation: Berechnung von Taupunkt und relativer Feuchte. Since the temperature inside the house should not fall below zero degrees, the calculation only works for positive values. For outside, there would still need to be a query, details can be found on the website mentioned.
The OpenWeatherMap integration is required to get the air pressure. The temperature must be in degrees Celsius, otherwise first convert from Kelvin to Celsius. The result is rounded to two digits and corresponds exactly to the results of the online calculators.
- platform: template
sensors:
scd30_abs_luftfeuchtigkeit:
value_template: >-
{% set r = states('sensor.scd30_rel_luftfeuchtigkeit') | float(default=0) %}
{% set t = states('sensor.scd30_temperatur') | float(default=0) %}
{% set p = states('sensor.openweathermap_pressure') | float(default=0) %}
{% set sdd = 6.1078 * 10**((7.5 * t)/(237.3 + t)) | float(default=0) %}
{% set dd = r/100 * sdd | float(default=0) %}
{% set af = 10**5 * 18.016/8314.3 * dd/ (t + 273.15) | float(default=0) %}
{{round(af , 2)}}
unit_of_measurement: "%"
Since typing that, this is what I tried and I just got it working. Now my microclimates in my grow rooms will have an average vpd on screen. I love it. Thanks for checking back.
In case you’re somewhere in the world where your sensors are in Celcius (not F), then I found it easiest to add an additional line to convert between C → F for the remainder of the math to work:
sensor:
- platform: template
sensors:
vapor_deficit:
unique_id: 'vpd_in_kpa'
friendly_name: 'VPD in kilo pascals'
value_template: >-
{% set TC = ((states('sensor.co2_1_temperature') | float) - 32) * 5/9 %}
{% set T = (TC * 5 / 9 + 32 | round(2)) %}
{% set RH = states('sensor.co2_1_humidity')|float %}
{% set SVP = 0.61078 * e ** (17.2694 * T / (T + 238.3)) %}
{% set VPD = ((100-RH) / 100) * SVP %}
{{-VPD | round(2) -}}
unit_of_measurement: 'kPa'
Hopefully that’s useful to somebody
Big thanks to @t_rage for the original calculations!
Has anyone figured out how to display a chart with the VPD shown? Something like how VPDChart.com allows you to dump in the data and then displays where you are at? Maybe a color change when it’s off?
I do exactly this…or rather did. I haven’t grown anything with home assistant since 2021. I’ll need to find my Pi, remove the SD card, and look through my data to figure out what I used. Feel free to hit me up on Instagram at rage_of_t to remind me if I happen to forget. In fact…my insta has pictures of these charts in use.
I know this is old but it is exactly what I was looking for! One thing though, is that the room VPD and the leaf VPD are two different equations and cannot be used just by replacing the temperature in one another (more info here: The Ultimate Vapor Pressure Deficit (VPD) Guide - Pulse Grow). This is what I ended up with (in °C):
- platform: template
sensors:
tent_vpd:
friendly_name: "VPD Carpa"
icon_template: mdi:waves-arrow-up
value_template: >-
{% set T = states('sensor.temperatura_indoor')|float %}
{% set RH = states('sensor.humedad_indoor')|float %}
{% set SVP = 0.61078 * e ** (T / (T + 237.3) * 17.2694) %}
{% set VPD = SVP * ((100 - RH) / 100) %}
{{-VPD | round(2) -}}
unit_of_measurement: 'kPa'
- platform: template
sensors:
leaf_vpd:
friendly_name: "VPD Hoja"
icon_template: mdi:waves-arrow-up
value_template: >-
{% set T = states('sensor.temperatura_indoor')|float %}
{% set RH = states('sensor.humedad_indoor')|float %}
{% set LTO = states('input_number.leaf_temperature_offset')|float %}
{% set LT = T + LTO %}
{% set ASVP = 0.61078 * e ** (T / (T + 237.3) * 17.2694) %}
{% set LSVP = 0.61078 * e ** (LT / (LT + 237.3) * 17.2694) %}
{% set LVPD = LSVP - (ASVP * RH / 100) %}
{{-LVPD | round(2) -}}
unit_of_measurement: "kPa"
Hi Bogdan, Thanks for the VPD chart, its great. Im also wondering if there is a way we can pull out the VPD value to be able to use it in automations, grafana, etc