BME 680 Pressure Rising/Falling

Good Evening,

I am working with a BME680. I have successfully converted the measurement into inHg.

What I would like to do next is have a sensor which reports if the pressure seems to be rising or falling to indicate weather patterns. I have been unable to find anything in the documentations or forums.

Current code is below, hoping someone can help.

  - platform: bme680
      name: "${namefull}_Pressure"
      unit_of_measurement: "inHg"
        - lambda: return x * 0.02953;

An approach you might consider - all doable within ESPHome:

  1. Apply a filter to your sensor, to smooth its value over time (to avoid frequent notifications due to normal sensor-jitter).
  2. Define a global or number component to store the ‘last’ sensor value.
  3. implement an automation that compares, on value_change, the present reading to the ‘last’ reading, and takes action accordingly (e.g. sends notifications, etc).

Your definition of when to store a ‘last’ value, and of the smoothing filters, will depend heavily on how much, or little, you want to be alerted to reversings of the slope of the sensor’s trendline.

Edit: I don’t mind smoothing out the pressure range, but I would rather have the raw data into HA, which is why I tried to use a template number.
If others have smoothed the data out just fine and recommend not bothering with the template number I would be interested in hearing about that too.

Ooo, I like this! I am struggling to figure out how to do it though. This is what I have created:

  - platform: bme680
      name: "${namefull}_Temperature"
      oversampling: 16x
      name: "${namefull}_Pressure"
      unit_of_measurement: "inHg"
      id: actual_pressure
        - lambda: return x * 0.02953;
          - number.set:
            id: pressure_average
            value: !lambda 'return x;'
      id: "humidity"
      name: "${namefull}_Humidity"
      id: "gas_resistance"
      name: "${namefull}_Gas_Resistance"
    address: 0x77
    update_interval: 60s
  - platform: template
    name: "${namefull}_Indoor_Air_Quality"
    id: iaq
    icon: "mdi:gauge"
    # caulculation: comp_gas = log(R_gas[ohm]) + 0.04 log(Ohm)/%rh * hum[%rh]
    lambda: |-
      return log(id(gas_resistance).state) + 0.04 *  id(humidity).state;

# I would like to build a binary sensor to toggle when this number is rising or falling.
    platform: template
    name: "${namefull}_Pressure_Average"
    id: pressure_average
    internal: true
    optimistic: true
    min_value: 25
    max_value: 35
    step: 0.01

This does not smooth the data however.

Also in step 3 do I use a binary sensor? Im not sure how to pass it through to HA without it being something that HA can turn on/off or rising/falling


For smoothing the input value, try adding one of the averaging filters.

Then look into the automation section of the ESPHome docs on how to implement an 'on_value…" trigger to your sensor, so when it gets a new value, you go compare it to the historical value, and can have it take action at that point if you wish.

There’s a LOT more to what ESPHome can do than I could convey in the meta-pseudo-code idea I described above and in the previous post. Those are just to give you a general idea of ONE (of many possible) ways to approach the solution.
Lots to read …

Maybe the derivative helper is what you’re looking after?

I didn’t finish but I was trying to copy my old manual barometer

Edit: there is a pressure gauge card but it is horribly out of date and there is a space for a proper pressure gauge with high and low points for last 24 hours

- sensor:
    - name: "Pressure Trend"
      unique_id: pressuretrend
      device_class: enum
      icon: mdi:gauge
      state: >
        {% set pressurederiv = states('sensor.pressure_derivative_3hr')|float %}
        {% if pressurederiv <= -5 %}falling very rapidy
        {% elif pressurederiv <= -3 %}falling rapidy
        {% elif pressurederiv <= -2 %}falling
        {% elif pressurederiv <= -1 %}falling gently
        {% elif pressurederiv <= 0 %}steady
        {% elif pressurederiv <= 1 %}rising gently
        {% elif pressurederiv <= 2 %}rising
        {% elif pressurederiv <= 3 %}rising rapidly
        {% elif pressurederiv <= 5 %}rising very rapidy
        {%- endif %}

    - name: "Pressure Weather"
      device_class: enum
      icon: phu:air-pressure
      state: >
        {% set pressure = (states('sensor.pressure_external_average')|float ) | round(0) %}
        {%set trend = states('sensor.pressure_trend') %}
        {% if pressure <= 960 %}stormy, {{pressure}}, {{trend}}
        {% elif pressure <= 990 %}Rain, {{pressure}}hPa, {{trend}}
        {% elif pressure <= 1050 %}Change, {{pressure}}hPa, {{trend}}
        {% elif pressure <= 1025 %}Fair, {{pressure}}hPa, {{trend}}
        {% elif pressure <= 1045 %}Dry, {{pressure}}hPa, {{trend}}
        {% elif pressure <= 1070 %}Very Dry, {{pressure}}hPa, {{trend}}
        {% elif pressure <= 1090 %}Scorchio, {{pressure}}hPa, {{trend}}
        {%- endif %}

Thanks all! I have to step away from this project for a bit but I will share updates if/when I return to it.