The statistics sensor is a very useful sensor but a bit crippled as it is limited by the number of samples it is given in the setup. It has been improved with the addition of the max_age
parameter but it is still not possible to use time only as limits. When using the sensor for data smoothing (LP filtering) a sample size setting is enough (using a time setting only might not even work) but in many other cases the situation is the opposite.
A simple example is averaging temperatures over a time period - how many samples do you need? Most temperature sensors report a new value only when a certain change is detected, typically 0.2-0.5 deg C. In a relatively stable environment you might only need 10-20 samples per day but in other cases you might need 10-20 samples per hour.
In my eyes the users shouldn’t have to worry about the sample size (unless they want to), it should be enough to set a time frame. I therefore suggest making both max_age
and sampling_size
optional and without default values.
What do you think?