Utility Meter adding extra readings to usage

I am currently using a trigger sensor to gather the current level of my propane tank and convert it to a usable format for the Energy dashboard and Utility Meter. Below is my trigger sensor and propane tank volume normalizer, which I shamelessly stole from someone.

template:
  - trigger:
      - platform: state
        entity_id: 'sensor.propanetank_propane_level'
        not_to:
          - unknown
          - unavailable
          - nan
    sensor:
        name: "Propane Volume"
        unique_id: propane_volume
        device_class: gas
        state_class: total_increasing
        unit_of_measurement: 'ft³'
        state: "{{ ( states('sensor.propanetank_propane_level') | float(0) * -1.33681 ) + 133.681 }}"

The reason for the trigger is to ignore readings if my ESP32 device goes offline or is unable to connect to the propane tank device for any period of time. A reading of unavailable throws my utility meter all out of whack.

The issue that I’m running into is that there is sometimes minor fluctuations (generally a gallon or so) due to environmental factors. So my propane level may go up and down a few times which in turn causes the propane volume to go up and down.

This in turn causes my utility meter which takes propane volume as input to add the “usage” more than once. Each one of the small step ups in usage corresponds to a drop and rise in the propane volume/level.

The top 2 pics are the propane level and volume and the bottom one is the utility meter usage:

I’m sure this is something simple that I’m overlooking, but I’ve been looking at it for far too long – also, I’m somewhat of a n00b, so it’s also likely that I just don’t know WTF I’m doing.

Any ideas on getting this sorted? Thanks!

You can modify the template sensor so it ignores values that are slightly smaller than the previous value (but allows values that are a lot smaller so that tank refills are still passed through).

I have no idea what values you want to filter out so change the -10 number in the last line to whatever makes sense.

template:
  - trigger:
      - platform: state
        entity_id: 'sensor.propanetank_propane_level'
        not_to:
          - unknown
          - unavailable
          - nan
    sensor:
        name: "Propane Volume"
        unique_id: propane_volume
        device_class: gas
        state_class: total_increasing
        unit_of_measurement: 'ft³'
        state: >
          {% set new_val = states('sensor.propanetank_propane_level') | float(0) * -1.33681 + 133.681 %}
          {% set old_val = this.state | float(0) %}
          {% set delta = new_val - old_val %}
          {{ old_val if 0 > delta > -10 else new_val }}

See also Filter - Home Assistant to deal with noisy signals.