* Correct time on recorder loaded values in statistics sensor
Previously, the current time was used when initial values was loaded
form the recorder component. This changes that to use the stored time
from recorder instead.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
* Expose min / max age of values in the statistics sensor
This is very useful when doing derived calculations, for example in a
template sensor.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
* Fix statistics sensor mean and median when only one sample is available.
With only one data point stddev and variance throw an exception.
This would clear the (valid) mean and median calculations.
Separate the try..catch blocks for one-or-more and two-or-more stats so
that this doesn't happen.
Test this with a new sampling_size_1 test.
* test_statistics trivial whitespace fix
* Initializing statistics sensor with data from database
* fixed broken test case
* usage of recorder component is now optional, thx to @andrey-git
* added test case for initialize_from_database