Calculating Vapor Pressure Deficit (or VPD) in kPa

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 :slightly_smiling_face:
Big thanks to @t_rage for the original calculations!

2 Likes

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.

Hi there!
I am one of the creators of vpdchart.com. We have just released a VPD chart card for HA: GitHub - vpdchart/vpdchart-card: A VPD chart card for Home Assistant
Hope you find it useful.

1 Like

I can’t get this to install through Hacs. The url doesn’t work.

I got it to work but thr url you have for hacs install doesn’t work. Used the github repo url

You can’t install it via HACS yet, because the repo is still waiting for approvement as a HACS default repository.

Now, the plugin is installable via HACS

Is there a way to not just chart the current VPD but record the VPD over time in HA? Like to create an entity with a state that is recorded?

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"

Cheers, also if you have a non contact temperature sensor you can use:

   - platform: template
    sensors:
      tent_vpd:
        friendly_name: "Canopy VPD"
        icon_template: mdi:waves-arrow-up
        value_template: >-
          {% set T = states('sensor.atom_canopy_average_temperature')|float %}
          {% set RH = states('sensor.atom_canopy_average_humdity')|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: "Canopy Leaf VPD"
        icon_template: mdi:waves-arrow-up
        value_template: >-
         {% set T = states('sensor.atom_canopy_average_temperature')|float %}
         {% set RH = states('sensor.atom_canopy_average_humdity')|float %}
         {% set LT = states('sensor.atom_leaf_temperature')|float %}
         {% 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"

esphome Which infrared temperature sensor did you use?

MLX90614 aka None Contact IR (NCIR) Sensor

I tried to use the MLX90614 sensor, but found that there is no esphome related code. How did you code it?

Here you go: https://github.com/3gyptian/esphome-mlx90614-i2c_IR_temp_sensor

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

1 Like