Help with Statistics Integration and Change function for Rain Gauge

Hey all,

I have been poking around the forums and google for help, but have yet to find anything that quite explains things in a way I can use it.

I have an Acurite rain gauge that transmits total cumulative rainfall about once a minute. In order to better chart things out in Grafana I want to feed the change per reading into influxdb.

I found the statistics integration with the change function and it seems to be what I need, but I cannot quite figure out how I should set it up.

Currently it is like this in my config file:

  - platform: statistics
    name: "precipitation change"
    entity_id: sensor.percipertation
    state_characteristic: change
    max_age:
        minutes: 2
    sampling_size: 3
    precision: 2
    unique_id: "precip1_change"

And it works for a few measurements, but after the buffer fills it just stops updating the changes.

You can see in my grafana chart how it is behaving.

The station is updating about once every minute (it occasionally skips a minute), but the change function does 1 or 2 measurements then missed a measurement, the 7 minutes was a quick restart as I tweaked configs.

I can understand it not reporting a change if that value hasn’t changed in a long time, however, it would be nice to have it do it for every received measurement.

My ideal situation would be for it to always compare the previous and the most recent calculation no matter the age of the previous value. Pretty much just hold the value1 until value2 comes in, subtract value1 from value2, report change1, then replace value1 with value2 and wait for value3, rinse repeat. I cannot seem to tweak the configuration to achieve that.

I hope my ramblings make sense.

So I have changed the config a little to try and get things working as I want, but it still isn’t quite right.

  - platform: statistics
    name: "precipitation change"
    entity_id: sensor.percipertation
    state_characteristic: change
    max_age:
        minutes: 2
    sampling_size: 4
    precision: 2
    unique_id: "precip1_change"

This seems to get me close to always comparing the most recent reading to the previous reading, but I am guessing the max-age and sample size are still conflicting.

Every 10ish minutes there is a hiccup in the change function.

Is there another way besides this change function to do what I am looking for?