Trend gradient is never zero

Hi,

I use trend for gas consumption meter in order to calculate gas consumption from the gradient.
What I observe is that even if gas is not consumed for some period of time the gradient is not changing to zero only still has the value from last moment the gas was consumed. I guess that maybe the reason is the sensor is not changing value so trend is not updated with new data. But this cause that trend is blind for flat (not changing) sensor value and will never has zero value, so I always see like I’m consuming the gas even if at the particular time I’m not consuming.

Is there better alternative to calculate usage in some period of time like last minute or 10 minutes from cumulative value sensor that always have only total value? By better alternative I mean something directly supported by Home Assistant and not writing program that will keep and use historical values…

Thank!