Yet another fun exercise to calculate something!
Pressure sensors measure the pressure on their altitude, but we eventually want the pressure at sea-level, for example to check with the weather forecast.
That can be done, by using some equations, if we have a sensor that can measure temperature, humidity and pressure (for example a BME280):
template:
- sensor:
- name: "Pressure sea level"
unique_id: "pressure_red"
state: |-
{%- set g0 = 9.80665 %}
{%- set RG = 287.05 %}
{%- set Ch = 0.12 %}
{%- set a = 0.0065 %}
{%- set h = 162.0 %}
{%- set p = states('sensor.outdoor_pressure') | float %}
{%- set phi = 0.01 * (states('sensor.outdoor_humidity') | float) %}
{%- set t = (states('sensor.outdoor_temperature') | float) %}
{%- set T = 273.15 + t %}
{%- set E = phi * 6.112 * e**((17.62 * t) / (243.12 + t)) %}
{%- set x = (g0 / (RG * (T + Ch * E + a * (h / 2)))) * h %}
{{ (p * e**x) | round(1) }}
icon: "mdi:gauge"
unit_of_measurement: 'hPa'
state_class: "measurement"
device_class: "pressure"
The only thing you have to set is the height (h
) in meters.