* always export max_age/min_age
* downgrade errors of missing data
on start with empty recorder database these errors are logged multiple times:
ERROR (MainThread) [homeassistant.components.sensor.statistics] mean requires at least one data point
ERROR (MainThread) [homeassistant.components.sensor.statistics] variance requires at least two data points
downgrade them to debug as they are not meaningful to end users
* add change_rate attribute
this calculates the average change rate of all data points
* simplify count, reorder attribute calculation
* reorder initialization
* reorder attribute names
* don't use min/max for min_age/max_age
* add test case
* style
* style
* sort constants
* init variables with None
* add precision config setting
* round to precision
* test round
* Upgrade pylint to 1.8.1
* Fix no-else-return
* Fix bad-whitespace
* Fix too-many-nested-blocks
* Fix raising-format-tuple
See https://github.com/PyCQA/pylint/blob/master/doc/whatsnew/1.8.rst
* Fix len-as-condition
* Fix logging-not-lazy
Not sure about that TEMP_CELSIUS though, but internally it's probably just like if you concatenated any other (variable) string
* Fix stop-iteration-return
* Fix useless-super-delegation
* Fix trailing-comma-tuple
Both of these seem to simply be bugs:
* Nest: The value of self._humidity never seems to be used anywhere
* Dovado: The called API method seems to expect a "normal" number
* Fix redefined-argument-from-local
* Fix consider-using-enumerate
* Fix wrong-import-order
* Fix arguments-differ
* Fix missed no-else-return
* Fix no-member and related
* Fix signatures-differ
* Revert "Upgrade pylint to 1.8.1"
This reverts commit af78aa00f125a7d34add97b9d50c14db48412211.
* Fix arguments-differ
* except for device_tracker
* Cleanup
* Fix test using positional argument
* Fix line too long
I forgot to run flake8 - shame on me... 🙃
* Fix bad-option-value for 1.6.5
* Fix arguments-differ for device_tracker
* Upgrade pylint to 1.8.2
* 👕 Fix missed no-member
* 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