Commit Graph
105 Commits
Author SHA1 Message Date
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 KostonandPaulus Schoutsen 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 KostonandMartin Hjelmare 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 KostonandPaulus Schoutsen 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 NijhofandMartin Hjelmare 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 KostonandMarc Mueller 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
J. Nick Koston 2cbb93be43 Always keep the current recorder run when purging (#43733) 2020-11-30 09:13:50 +01:00
J. Nick Koston 4ab02cb9bc Ensure recorder commit can retry after encountering invalid data (#41426) 2020-10-08 09:15:25 +02:00
J. Nick Koston 113d738fa2 Reduce orm overhead by grouping object expiration (#41394) 2020-10-07 15:35:48 +02:00
Ariana Hlavaty 1e9e40bf71 Rewrite recorder unittest tests to pytest style test function (#41264) 2020-10-06 21:24:13 +02:00
J. Nick Koston 20a136e2a1 Avoid event data serialization during recorder that we throw away (#41217)
We currently serialize the event data for state change events
and then replace it because we save the state in the states table.
Since the old state and new state are both contains in the event
the cost of serializing the data has a noticable impact when there
are many state changed events.
2020-10-05 15:08:47 +02:00
J. Nick Koston d9ba32dc3f Setup recorder model relationships to avoid calling flush (#40467) 2020-09-30 13:11:43 +02:00
J. Nick Koston 557684c3ce Add ability to disable the sqlite3 quick_check (#39479) 2020-09-02 10:12:56 +02:00
J. Nick Koston 56ddbd87b2 Fix recorder test intermittently failing (#39468) 2020-08-30 13:58:00 -05:00
J. Nick Koston 45401d4308 Fix flapping recorder last run test (#39134) 2020-08-22 09:35:18 +02:00
J. Nick Koston 7c346c2f7c Skip the sqlite quick_check on clean restarts (#38972) 2020-08-21 14:20:46 +02:00
J. Nick Koston 7878d97588 Use SimpleQueue for recorder (#38967)
Now that python 3.7 is the minimum supported version, we can
use the more efficient SimpleQueue in the recorder as it does
not have to use threading.Lock
2020-08-21 13:54:13 +02:00
Bas Nijholt 0427d87ba4 Bump codespell from v1.16.0 to v1.17.1 and fix new spelling errors (#38663) 2020-08-08 14:41:02 +02:00
J. Nick Koston 60009ec2f9 Use event loop scheduling for tracking time patterns (#38021)
* Use event loop scheduling for tracking time patterns

* make patching of time targetable

* patch time tests since time can tick to match during the test

* fix more tests

* time can only move forward

* time can only move forward

* back to 100% coverage

* simplify since the event loop time cannot move backwards

* simplify some more

* revert simplify

* Revert "revert simplify"

This reverts commit bd42f232f6f4e0876fbfe7ce5abf363779761acd.

* Revert "simplify some more"

This reverts commit 2a6c57d51487d4fc85140033a5cadbc800e61287.

* Revert "simplify since the event loop time cannot move backwards"

This reverts commit 3b13714ef489b5c5661ae0254b12f137d047fc26.

* Attempt another simplify

* time does not move backwards in the last two

* remove next_time <= now check

* fix previous merge error
2020-07-20 20:18:31 -10:00
J. Nick Koston 1acdb28cdd Automatically recover when the sqlite3 database is malformed or corrupted (#37949)
* Validate sqlite database on startup and move away if corruption is detected.

* do not switch context in test -- its all sync
2020-07-17 19:07:37 -10:00
J. Nick Koston 4b2ebf5487 Ensure removed entities are not displayed in logbook (#37395) 2020-07-03 23:08:46 -07:00
Franck Nijhof 79f131066c Ensure recorder data integrity and MySQL lock error handling (#37228) 2020-06-29 16:23:11 -07:00