Paulus Schoutsen
eba1d7d16a
Guard for bad last reset ( #57344 )
2021-10-08 10:48:52 -07:00
Erik Montnemery
69875cbd11
Improve sensor statistics validation ( #56892 )
2021-10-04 09:47:44 -07:00
Erik Montnemery
6af1a835e6
Optimize statistics generation ( #56821 )
...
* Optimize statistics generation
* pylint
2021-09-30 17:14:36 +02:00
Erik Montnemery
6954614e62
Warn if total_increasing sensor has negative states ( #56564 )
2021-09-30 07:49:16 -07:00
Erik Montnemery
8c3fc95fb8
Fallback to state machine in statistics ( #56785 )
2021-09-29 14:57:16 -07:00
Erik Montnemery
40ecf22bac
Remove automatic splitting of net meters from statistics ( #56772 )
2021-09-29 17:20:17 +02:00
Marc Mueller
364767ff22
Import Callable from collections.abc (4) ( #56778 )
2021-09-29 16:15:36 +02:00
Erik Montnemery
552485bb05
Tweak list_statistic_ids ( #55845 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-09-28 00:05:26 -07:00
Erik Montnemery
58f465f271
Don't reset meter when last_reset is set to None ( #56609 )
2021-09-27 12:17:09 +02:00
Erik Montnemery
7452998081
Convert last_reset timestamps to UTC ( #56561 )
...
* Convert last_reset timestamps to UTC
* Add test
* Apply suggestion from code review
2021-09-24 09:16:50 +02:00
Erik Montnemery
92253f5192
Minor refactoring of periodic statistics ( #56492 )
2021-09-22 13:31:33 -07:00
Erik Montnemery
6f36419c6f
Improve statistics validation ( #56457 )
2021-09-20 17:54:25 +02:00
Erik Montnemery
d899d15a1e
Add statistics validation ( #56020 )
...
* Add statistics validation
* Remove redundant None-check
* Move validate_statistics WS API to recorder
* Apply suggestion from code review
2021-09-13 13:44:22 +02:00
Erik Montnemery
89281a273c
Correct confusing log message in sensor statistics ( #56016 )
2021-09-09 23:26:29 -07:00
Erik Montnemery
80fd330479
Add sum_decrease and sum_increase statistics ( #55850 )
2021-09-08 23:35:53 -07:00
Erik Montnemery
27764e9985
Fix handling of imperial units in long term statistics ( #55959 )
2021-09-08 08:08:48 -07:00
Erik Montnemery
9f1e503784
Do not allow `inf` or `nan` sensor states in statistics ( #55943 )
2021-09-08 08:05:16 -07:00
Erik Montnemery
b99a22cd4d
Re-add state_class total to sensor ( #55103 )
...
* Re-add state_class total to sensor
* Make energy cost sensor enforce state_class total_increasing
* Bump deprecation of last_reset for state_class measurement
* Correct rebase mistakes
2021-09-06 18:28:58 +02:00
Erik Montnemery
38d42de2c0
Handle negative numbers in sensor long term statistics ( #55708 )
...
* Handle negative numbers in sensor long term statistics
* Use negative states in tests
2021-09-04 10:47:42 +02:00
Erik Montnemery
93c086d830
Correct sum statistics when only last_reset has changed ( #55498 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-08-31 21:30:52 -07:00
Erik Montnemery
5d1a193eca
Improve log for sum statistics ( #55502 )
2021-08-31 19:15:22 +02:00
Erik Montnemery
f9225bad5f
Make new cycles for sensor sum statistics start with 0 as zero-point ( #55473 )
2021-08-31 10:45:17 +02:00
Erik Montnemery
722aa0895e
Improve statistics error messages when sensor's unit is changing ( #55436 )
...
* Improve error messages when sensor's unit is changing
* Improve test coverage
2021-08-30 12:51:46 +02:00
Erik Montnemery
7e70252de5
Handle statistics for sensor with changing state class ( #55316 )
2021-08-27 16:18:49 +02:00
Erik Montnemery
0a07ff4d23
Warn if a sensor with state_class_total has a decreasing value twice ( #55251 )
2021-08-26 14:27:14 +02:00
Erik Montnemery
bb42eb1176
Warn if a sensor with state_class_total has a decreasing value ( #55197 )
2021-08-25 13:01:55 +02:00
Erik Montnemery
ffbd2d79c8
Generate statistics for all sensors with a supported state_class ( #54882 )
...
* Generate statistics for all sensors
* Fix bugs, add tests
* Address review comments
* Cleanup warnings
* Simplify tests
* Simplify selection of statistics
* Fix tests
2021-08-25 13:00:35 +02:00
Erik Montnemery
fa9f91325c
Allow small dip in total_increasing sensor without detecting a reset ( #55153 )
2021-08-24 17:23:55 +02:00
Erik Montnemery
8877f37da0
Fix statistics for sensors setting last_reset ( #55136 )
...
* Re-add state_class total to sensor
* Make energy cost sensor enforce state_class total_increasing
* Drop state_class total
* Only report energy sensor issues once
2021-08-24 17:02:34 +02:00
Erik Montnemery
0624859bf4
Set statistics columns to double precision ( #55053 )
2021-08-24 11:18:59 +02:00
Erik Montnemery
e1926caeb9
Remove STATE_CLASS_TOTAL and last_reset from sensor ( #54755 )
...
* Remove STATE_CLASS_TOTAL
* Update mill sensor
* Update tests
* Kill last_reset
* Return ATTR_LAST_RESET to utility_meter
* Update energy cost sensor
* Restore last_reset for backwards compatibility
* Re-add and update deprecation warning
* Update tests
* Fix utility_meter
* Update EnergyCostSensor
* Tweak
* Fix rebase mistake
* Fix test
2021-08-18 10:03:27 +02:00
Erik Montnemery
3a78f1fce6
Force STATE_CLASS_TOTAL_INCREASING to reset to 0 ( #54751 )
...
* Force STATE_CLASS_TOTAL_INCREASING to reset to 0
* Tweak
* Correct detection of new cycle
* Fix typing
2021-08-17 23:05:31 +02:00
Erik Montnemery
029873a088
Add support for total and total_increasing sensor state classes ( #54523 )
...
* Add support for amount and meter sensor state classes
* Ignore last_reset for STATE_CLASS_METER sensors
* Update tests
* Rename STATE_CLASS_METER to STATE_CLASS_AMOUNT_INCREASING
* Rename STATE_CLASS_AMOUNT to STATE_CLASS_TOTAL
* Fix typo
* Log warning if last_reset set together with state_class measurement
* Fix warning message
2021-08-13 12:35:23 +02:00
Bram Kragten
e23750b2a4
Add device class `gas` and enable statistics for it ( #54110 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-08-11 09:58:19 -07:00
Paulus Schoutsen
f71980a634
Create stats for all sensors that have % unit and are measurement ( #53576 )
2021-07-27 21:56:34 +02:00
Erik Montnemery
ddc788bf8e
Include future statistics in history/list_statistic_ids ( #52942 )
...
* Include future statistics in history/list_statistic_ids
* Improve tests
2021-07-14 11:54:55 +02:00
Erik Montnemery
19d3aa71ad
Enable basic type checking for recorder ( #52440 )
...
* Enable basic type checking for recorder
* Tweak
2021-07-13 21:21:45 +02:00
Erik Montnemery
24ae05b734
Drop statistic_id and source columns from statistics table ( #52417 )
...
* Drop statistic_id and source columns from statistics table
* Remove useless double drop of statistics table
* Update homeassistant/components/recorder/models.py
Co-authored-by: Franck Nijhof <git@frenck.dev>
* black
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-07-02 13:17:00 +02:00
Erik Montnemery
16d2dcbfb2
Improve sensor statistics tests ( #52386 )
2021-07-02 09:51:47 +02:00
Erik Montnemery
57fbb1c3d9
Fix sensor statistics collection with empty states ( #52393 )
2021-07-01 14:53:03 +02:00
Erik Montnemery
0476c7f9ee
Normalize temperature statistics to °C ( #52297 )
...
* Normalize temperature statistics to °C
* Fix tests
* Support temperature conversion to and from K, improve tests
* Fix test
* Add tests, pylint
2021-06-30 14:17:58 +02:00
Erik Montnemery
0ab999738b
Add statistics meta data table ( #52331 )
...
* Add statistics meta data table
* Tweak meta data generation
2021-06-30 13:32:17 +02:00
Erik Montnemery
cca5964ac0
Normalize pressure statistics to Pa ( #52298 )
2021-06-29 23:30:13 +02:00
Erik Montnemery
6131ed09f0
Compile statistics for power sensors ( #52299 )
2021-06-29 14:48:08 +02:00
Erik Montnemery
c785db4ffa
Normalize energy statistics to kWh ( #52238 )
2021-06-29 12:20:10 +02:00
Erik Montnemery
a374e24843
Add monetary sensor device class ( #52087 )
...
* Add total_cost sensor device class
* Change to DEVICE_CLASS_MONETARY
2021-06-23 15:32:25 +02:00
Erik Montnemery
b339d73109
Weight sensor average statistics by state durations ( #51150 )
...
* Weight sensor average statistics by state durations
* Fix test
2021-05-28 13:16:52 +02:00
Erik Montnemery
6f26687aa7
Compile statistics for battery, humidity and pressure sensors ( #50920 )
2021-05-21 10:48:11 +02:00
Daniel Hjelseth Høyer
fd2e640c74
Use sensor constants in recorder ( #50906 )
...
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
2021-05-20 18:23:00 +02:00
Erik Montnemery
e16a8063a5
Compile statistics for energy sensors ( #50829 )
...
* Compile statistics for energy sensors
* Update tests
* Rename abs_value to state
* Tweak
* Recreate statistics table
* Pylint
* Try to fix test
* Fix statistics for multiple energy sensors
* Fix energy statistics when last_reset is not set
2021-05-20 13:05:15 +02:00