Template to calculate barometric pressure (QFF)

Good evening,
Ich have a sensor (Lumi) that measures pressure and temperature. With the two values (and the altitude of the location [Thun in Switzerland) i’d like to calculate the pressure reduced to the sea level. I manged to get the the required code running in Development Tool/Template of Home Assistant. Means the code calculates the correct pressure (see screenshot in the attachment). Now im a bit puzlled, what are the next steps, to integrate this tested code in home assistant? Any help will be appreciated.

Regards

Hans Peter

template:

  • sensor:
    • name: “Luftdruck_QFF”
      unit_of_measurement: ‘hPa’
      value_template: >-
      {{ (states(‘sensor.lumi_lumi_weather_pressure’)|float / (1-0.0065*561/ (states(‘sensor.lumi_lumi_weather_temperature’)|float + 273.15 )) ** (5.255)) |round(1) }}

Since you have your formula working I suggest you create a template helper (you find them in the UI under settings) and paste your working formula into that. This helper you could use in HA for various things.

… and please paste your code using </> :slight_smile:
Like this:

{{ (states(‘sensor.lumi_lumi_weather_pressure’)|float / (1-0.0065*561/ (states(‘sensor.lumi_lumi_weather_temperature’)|float + 273.15 )) ** (5.255)) |round(1) }}

See number 11 in this post: How to help us help you - or How to ask a good question

Good morning,
Today I had some time to continue on “my problem”. I had a look into the (German) Book “Home ASSISTANT - Das umfassende Handbuch” (Author: Udo Brandes). There I found two ways to solve my problem:

  • Add the yaml code directly to the “configuration.yaml” file (or to a dedicated .yaml file and use the include directive).

  • Create a template helper as you suggested

Since this is my very first template, I followed your recommendation. As a result: It works!

Best regards an thanks a lot!

Hans Peter


1 Like