Tracking stats of an increasing sensor that resets

I have the Acurite 899 rain gauge. It outputs a rain total reading that is ever-increasing and I create statistics sensors that track hourly, daily and weekly totals. But today the device reset its reading to 0mm and threw off my statistics. How would you configure this to account for an unexpected reset? My gut says to transform the rain gauge reading into a separate template sensor that account for the reset somehow, but I’m not entirely sure how to configure that kind of stateful logic into a template (“if the current value is less than the last value…”). And am I thinking of it incorrectly and there is a better solution?

Utility meters do just that. Be sure to set the periodically_resetting to true, and no chcle. It will not fix the past however, but it will continue counting on the next reset.

Thank you so much, exactly the pointer I was looking for. I went looking at the docs of Utility Meter hoping it was the answer and somehow missed that feature.

EDIT: I plan to edit my data with SQL to fix today’s reset. I was just looking for a fix going forward.