Commit graph

171 commits

Author SHA1 Message Date
Erik Montnemery
6f36419c6f
Improve statistics validation (#56457) 2021-09-20 17:54:25 +02:00
Erik Montnemery
8c5efafdd8
Add 5-minute statistics for sensors (#56006)
* Add 5-minute statistics for sensors

* Address pylint issues

* Black

* Apply suggestion from code review

* Apply suggestions from code review

* Improve tests
2021-09-16 10:57:15 +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
d2a9f7904a
Include end time of statistics data points in API response (#56063)
* Include end time of statistics data points in API response

* Correct typing

* Update tests
2021-09-13 10:02:24 +02: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
22e6ddf8df
Do not let one bad statistic spoil the bunch (#55942) 2021-09-08 07:55:40 -07: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
32e297f4a0
Compile missing statistics (#54690) 2021-08-19 22:10:45 -07: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
Paulus Schoutsen
557cc792e9
Fix SQLAlchemy test warnings (#54116) 2021-08-08 20:33:47 -07:00
Erik Montnemery
e541bcd54d
Update statistics meta data on entity_id change (#52755) 2021-07-14 13:23:11 +02:00
Erik Montnemery
11fd9d9525
Avoid duplicated database queries when fetching statistics (#52433) 2021-07-02 15:40:54 +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
PeteBa
42c4317628
Avoid drift in recorder purge cut-off (#52135) 2021-06-25 11:29:38 -10:00
Paulus Schoutsen
805ef3f90b
Allow fetching multiple statistics (#51996) 2021-06-18 21:03:13 +02:00
Erik Montnemery
39c94e8daa
Fix flaky statistics tests (#51214)
* Fix flaky statistics tests

* Tweak
2021-05-28 22:37:17 +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
PeteBa
aa9b99713c
Add purge_entities service call to recorder (#48069) 2021-05-22 10:30:05 -05: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
J. Nick Koston
e7f7e61e88
Ensure a wal checkpoint is scheduled nightly (#50746) 2021-05-17 16:27:51 -05:00
J. Nick Koston
72288710ca
Increase the sqlite cache size from ~2MiB to 8MiB (#50747) 2021-05-17 19:42:12 +02:00
Erik Montnemery
89dd3292ba
Initial draft of statistics (#49852) 2021-05-16 10:23:37 -07:00
Erik Montnemery
973f59e423
Refactor history component (#50287)
* Refactor history component

* Update tests

* Address review comments

* Correct deprecated functions
2021-05-11 09:21:57 +02:00
J. Nick Koston
bf2d40adfe
Migrate from pytz to python-dateutil (#49643)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-07 22:46:26 -07:00
J. Nick Koston
1c8d9ca68b
Check exception causes for matching strings during recorder migration (#49999) 2021-05-02 20:57:42 -07:00
Paulus Schoutsen
1bd9826684
Handle different entity_id formats (#49969) 2021-05-01 20:30:28 -07:00
J. Nick Koston
b27e9e376d
Use StaticPool for recorder and NullPool for all other threads with sqlite3 (#49693) 2021-04-26 19:20:31 -10:00
jan iversen
c351098f04
HomeAssistantType —> HomeAssistant for Integrations p* - s* (#49558) 2021-04-22 19:58:02 +02:00
J. Nick Koston
c10836fcee
Upgrade to sqlalchemy 1.4.11 (#49538) 2021-04-21 20:29:36 -10:00
J. Nick Koston
6d137d2316
Increase recorder test coverage (#49362)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-04-19 08:22:38 -07:00
J. Nick Koston
e24f5831a2
Force recorder shutdown at final write event (#49145)
* Force recorder shutdown at EVENT_HOMEASSISTANT_FINAL_WRITE

* remove unreachable

* remove unreachable

* simplify

* cancel in async
2021-04-19 11:24:17 +02:00
J. Nick Koston
53853f035d
Prevent calling stop or restart services during db upgrade (#49098) 2021-04-12 17:18:38 -07:00
J. Nick Koston
9368891b1b
Live db migrations and recovery (#49036)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-04-11 20:43:54 -10:00
Laszlo Magyar
c7e4857d2c
Let recorder deal with event names longer than 32 chars (#47748) 2021-04-08 07:08:49 -10:00
Franck Nijhof
08870690a6
Fix a collection of tests with missing asserts (#48127)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-03-20 17:23:55 +01:00
Franck Nijhof
fb849b81b5
Rewrite of not a == b occurances (#48132) 2021-03-20 01:27:04 +01:00
J. Nick Koston
28c80c1133
Ensure recorder purge tests can handle multiple purge cycle (#47956)
Since a purge can generate another purge task, we now wait for
three recorder queue completions by default.
2021-03-15 11:19:19 -07:00
J. Nick Koston
61a2460c87
Improve error reporting in recorder purge test (#47929) 2021-03-14 19:46:21 -07:00
Erik Montnemery
2178e27fb4
Fix unclean shutdown of recorder test (#47791) 2021-03-12 14:17:27 -08:00
Marc Mueller
92852b9c10
Add apply_filter attribute to recorder.purge service (#45826) 2021-03-11 17:03:30 -10:00
Marc Mueller
10848b9bdf
Recorder improvements (#47739) 2021-03-11 07:52:07 -10:00
J. Nick Koston
a060acc2b1
Fix recorder with MSSQL (#46678)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-03-09 11:16:19 -10:00
adrian-vlad
44293a3738
Add enable and disable services for recorder (#45778) 2021-02-24 07:26:05 -06:00
J. Nick Koston
e2fd255a96
Cleanup recorder tests (#46836) 2021-02-21 09:52:41 +01:00
J. Nick Koston
9b69549f73
Recover and restart the recorder if the sqlite database encounters corruption while running (#46612) 2021-02-19 21:26:24 -10:00
J. Nick Koston
22dbac259b
Ensure recorder shuts down cleanly on restart before startup is finished (#46604) 2021-02-19 22:18:21 -08:00
J. Nick Koston
dc26fd5149
Ensure creating an index that already exists is forgiving for postgresql (#46185)
Unlikely sqlite and mysql, postgresql throws ProgrammingError instead
of InternalError or OperationalError when trying to create an index
that already exists.
2021-02-08 23:22:38 +01:00
Franck Nijhof
65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Allen Porter
f1dff973dc
Fix broken test test_auto_purge in recorder (#44687)
* Fix failing test due to edge-of-2021 bug

* Rewrite test_auto_purge to make the intent more clear
2020-12-31 12:04:12 -10:00