Learn how to calculate Absolute Humidity (AH) in Home Assistant to compare indoor and outdoor moisture levels.
Most sensors only show Relative Humidity (RH), but that doesn’t always tell the full story. By calculating Absolute Humidity (AH), you can actually compare the true amount of water vapor in the air indoors and outdoors. You can the display these values in Home Assistant.
I mainly use Absolute Humidity (AH) to decide whether it makes sense to open the windows. For example, if it’s raining outside, the relative humidity might seem high, but the absolute humidity might be lower than indoors – meaning opening the windows would actually reduce the moisture inside.
Table of Contents
Relative vs. Absolute Humidity
When most people talk about humidity, they talk about Relative Humidity. If you want to compare the moisture levels between indoors and outdoors, the more useful metric is absolute humidity (AH). It tells you how many grams of water vapor are present in one cubic meter of air (g/m3)
- Relative Humidity (RH): How “saturated” the air is with water vapor at a given temperature. Relative Humidity is most often expressed in %.
- Absolute Humidity (AH): The actual amount of water vapor in the air, it’s independent of temperature. Absolute Humidity is most often expressed in g/m3.
Example:
If you have 50% RH indoors at 25 °C, and 50% RH outdoors at 5 °C, the indoor air actually contains much more water – even though the RH is the same.
You can read more about relative and absolute humidity here.
How to Calculate Absolute Humidity?
Absolute Humidity (AH) is calculated from temperature °C and relative humidity in %.
I’m just gonna paste the formulas and spare you all the explanations.
The formula is the following for Celsius:
AH = (6.112 * e^((17.67 * T) / (T + 243.5)) * RH * 2.1674) / (273.15 + T)
Fahrenheit version:
AH = (6.112 * e^((17.67 * ((Tf – 32) / 1.8)) / (((Tf – 32) / 1.8) + 243.5)) * RH * 2.1674) / (273.15 + ((Tf – 32) / 1.8))
Where:
- AH = absolute humidity in g
- T = temperature in °C
- TF = temperature in °F
- RH = relative humidity in g/m3
If you want to know more about the formula, you can read about it here.
Home Assistant Configuration
Now onto the most important part – actually calculating and displaying the absolute humidity in Home Assistant.
Creating a Template Sensor
Go to Settings -> Devices and services -> Helpers -> Create Helper -> Template
Chose “Template a sensor”, give it a name and add the following code in the state field:
Be sure to update the entity IDs to match your own sensors.
Celsius Version:
{% set T = states('sensor.indoor_temperature')|float(0) %}
{% set RH = states('sensor.indoor_humidity')|float(0) %}
{% set Ps = 6.112 * e**((17.67 * T) / (T + 243.5)) %}
{{ ((Ps * RH * 2.1674) / (273.15 + T)) | round(2) }}
Fahrenheit version:
{% set Tf = states('sensor.indoor_temperature_f')|float(0) %}
{% set T = (Tf - 32) / 1.8 %}
{% set RH = states('sensor.indoor_humidity')|float(0) %}
{% set Ps = 6.112 * e**((17.67 * T) / (T + 243.5)) %}
{{ ((Ps * RH * 2.1674) / (273.15 + T)) | round(2) }}
Now complete the remaining template sensor settings (unit, device class, etc.).
- Unit of measurement: g/m³
- State class: Measurement
Here’s my configuration:

You should do the same for the absolute humidity outside.
Displaying the Sensor
This step is fairly simple, you are probably already familiar with adding entities to you dashboard.
Either way, I’ll show you:
Edit you dashboard and add a new tile/card.
Just chose the template sensor you made:

I changed the layout, so the card is 6 by 2 tiles:

Wrapping up
With your new Absolute Humidity sensor in Home Assistant, you can now easily compare your the indoor and outdoor moisture levels. This makes it much easier to decide when opening the windows in your home will actually help lowering the humidity inside. Especially when it’s raining it can be hard to decide.
From here, you can also build automations that will notify you when it’s a good time to open your windows, or just keep track of long term trends in the absolute humidity.
I hope this guided helped you set up your sensor for absolute humidity. If you found it useful, check out my other Home Assistant articles, I often share when i build new stuff for our home, maybe some of it would be interesting to you. You can find the rest of my Home Assistant content here.
Feel free to comment on the post if you have any questions. 😊