Absolute Humidity Template Sensor calculated from Relative Hum and Temp

I wanted a sensor that is just the calculated absolute humidity from relative humidity and temp, to provide a value that can be charted and used like any other weather value for automation and display.
It has been asked here and online a few times but the answer is either overcomplicated blueprints, the comfort sensors from that store/addon thing I don’t want or just out of date.

So if you are looking for a simple answer like me, here is what you do:
Settings → Devices & Services → Helpers (up top)
+Create Helper (bottom right)
Choose “Template”
Choose “Sensor”
Fill in

  • Name: shed absolute humidity
  • State:
{% set T = float(states('sensor.my_shed_sensor_temperature')) %}
{% set rh = float(states('sensor.my_shed_sensor_humidity')) %}
{% set aH = (6.112 * e**((17.67*T) / (T+243.5)) * rh * 2.1674) / (273.15+T) %}
{{ aH|round(2) }}
  • Unit of measurement: g/m3
  • Device Class: Absolute Humidity
  • State Class: Measurement (not sure what this one does TBH)
  • don’t bother with the rest and then press Submit, done!

Hopefully this will help anyone who also just wants a simple sensor, and save them 2 hours searching, figuring out how jinja works and the basics of weather science.

2 Likes

Awesome!

Thanks a lot for this, i adapted the formula to calculate the vapor-pressure-deficit (VPD) too:

{% set T = float(states('sensor.TEMPERATURESENSOR')) %}
{% set rh = float(states('sensor.HUMIDITYSENSOR')) %}
{% set es = (0.6108 * e**((17.27*T) / (T+237.3)) )%}
{% set ea = (rh/100) * es  %}
{% set vpd = es - ea  %}
{{ vpd|round(2) }}

1 Like

This is great, thank you.

However, I want to repeat it for about 15 sensors around the home. I don’t want to have to manually do this one by one. Is there some kind of abstraction that allows this to become an inherited property on each hardware device?