Calculate air pressure formula with math.pow

how to use the math.pow correctly?

  - platform: template
    sensors:
      air pressure:
        friendly_name: "air pressure"
        unit_of_measurement: hPa
        device_class: pressure
        value_template: >-
          {{states.sensor.pressure.state / math.pow((1-0.0065*600/297.05,.5.255)) }}

See Jinja Math.

You got some odd things going on right here:

Extra decimal place?

anyways, expanding on @pnbruckner’s response. This is the proper way to do power in python / jinja:

{{states.sensor.pressure.state / (1-0.0065*600/297.05) ** (5.255) }}

assuming that you want to raise (1-0.0065*600/297.05) to the (5.255) power.

So you work perfectly, thanks for the help

  - platform: template
    sensors:
      luftdruck:
        unit_of_measurement: 'hPa'
        value_template: >-
          {{ (float(states.sensor.pressure.state) / (1-0.0065*600/(float(states.sensor.temperatur.state) + 273.15 )) ** (5.255)) | round(1) }}

Calculate air pressure with barometer

1 Like

Thank you for this hint. Used it for my Wemos D1 + BME280 + Tasmota + KNX.
But how can the elevation setup from the configuration.yaml be used? This is:

homeassistant:
   elevation: 295

Tried this:

  - platform: template
    sensors:
      luftdruck:
        unit_of_measurement: 'hPa'
        value_template: >-
          {{ (float(states.sensor.luftdruck_garten.state) / (1-0.0065*float(elevation)/(float(states.sensor.temperatur_garten.state) + 273.15 )) ** (5.255)) | round(1) }}

But it didn´t work. How to use the elevation parameter in a formula?

Should have checked here … found that formula elsewhere yesterday and implemented it pretty much the same way - with the same question: How can I access the elevation that I already entered …?

Neither the bme280 component for homeassistant nor the esphome’s bme280 sensor code have any such correction.

- platform: template
    sensors:
      pressure_luftdruck:
        unit_of_measurement: 'hPa'
        value_template: >-
          {{ (states('sensor.0x00158d00023cfb3a_pressure')|float / (1-0.0065*611/ (states('sensor.0x00158d00023cfb3a_temperature')|float + 273.15 )) ** (5.255)) |round(1) }}

611 meter over sea … change this with the altitude where you are located
Maybe this will help you
https://rechneronline.de/barometer/

I see sensors which include pressure reading but I’m never sure what everyone is doing with them?

The only idea I’ve had is to place two of them one on either side of an air filter and look for a pressure drop which would mean it’s time to change the filter.

Right now my thermostat allows me to set 3month to 12 months and then pops up a message saying its time to change the filter.

Also has anyone come up with an automation which would turn on the HVAC Blower motor for an amount of time if the air quality is bad?? Kind of polishing the air. (good idea on not?) Also, same idea when the vacuum is running and stirring up some dust.