I want to calculate the gasflow rate in m3/h. So I figured, lets use a derivative sensor for this. After all, in a graph like this calculating the derivative is early high school math. However no matter what values I tried for the time window, the result is just super jittery (the bigger differences are caused by tweaking the time window sizes, but none worked without jitter):
In a clear-cut example like this, the derivative should be a constant value, but it wobbles around the actual value. I’ve also tried to smooth it using SMA, but still it displays the wobble, plus when smoothing it out too much, the flow sensor becomes really laggy, which is not ideal when wanting to know the flow rate.
If the sensor updates every 5 minutes, I should have a proper delta value every 5 minutes. Maximum lag shouldn’t be more than that. How to ensure this is the case?
I believe that data used a timeframe of 19 minutes. Using anything less was way more jittery. And a timeframe of 19 minutes isn’t really responsive, certainly not when the actual sensor updates every 5 minutes. And even with 19 minutes, the result isn’t a single value, it still jitters, only with a smaller amplitude.
But that is what you get when the chart is “zoomed” in all the way.
Your scale is 0.25 of change over half a day.
I’m not sure what you actually expect HA to do…
Indeed it is zoomed in, but the value is always circling around the real slope value (0.19 m3/h) that I can calculate by hand. Please do note that the gas consumption is constant, because the heating is switched on permanently.
Even though the consumption is constant, the min max in this graph is between 0.15 and 0.23. That’s a difference of 0.08, which is a huge fluctuation at those values.
I’d like to have a stable value, of say 0.19 (+/- a tiny bit of rounding errors). Not a rounding error of almost 50%.
Not sure what you think could be done here; the derivative is not subjective, the result is the result, based on your input data.
If you think the math is wrong, then provide your exact table of input data, and show how the calculation produces the wrong result, and show what equations you think should be used instead that produces a superior result.
It’s not fair to say you don’t like the way the result “looks”, without giving any evidence that it is incorrect.
If you want it smoothed over a longer time range, then you can choose that in the options, but yes then it will be less responsive to recent changes.
Actually not that hard to do.
(The logging of data)
Use the Google sheets integration and save the values coming from the gas meter and the derivative sensor.