Commit Graph
169 Commits
Author SHA1 Message Date
J. Nick KostonandGitHub 5a609c34bb Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
J. Nick KostonandGitHub d06932bbc2 Refactor asyncio loop protection to improve performance (#117295) 2024-05-13 07:01:55 +09:00
Erik MontnemeryandGitHub f5fe80bc90 Convert recorder init tests to use async API (#116918) 2024-05-06 07:59:39 -05:00
J. Nick KostonandGitHub 6339c63176 Improve recorder and worker thread matching in RecorderPool (#116886)
* Improve recorder and worker thread matching in RecorderPool

Previously we would look at the name of the threads. This
was a brittle if because other integrations may name their
thread Recorder or DbWorker. Instead we now use explict thread
ids which ensures there will never be a conflict

* fix

* fixes

* fixes
2024-05-05 16:25:10 -04:00
27fcf72275 Convert history tests to use async API (#116447)
* Convert history tests to use async API

* Add new fixture to help patch recorder

* Modify

* Modify

* Update tests/conftest.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Rename fixture

---------

Co-authored-by: Martin Hjelmare <[email protected]>
2024-05-03 08:14:46 +02:00
Erik MontnemeryandGitHub aa65f21be7 Fix flapping recorder tests (#116239) 2024-04-26 09:05:23 -05:00
Erik MontnemeryandGitHub 10be8f9683 Simplify timezone setting in recorder test (#116220) 2024-04-26 15:14:23 +02:00
J. Nick KostonandGitHub 5447a1a015 Ensure all tables have the default table args in the db_schema (#114895) 2024-04-05 08:22:00 +02:00
6bb4e7d62c Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <[email protected]>
Co-authored-by: Marc Mueller <[email protected]>
Co-authored-by: J. Nick Koston <[email protected]>
2024-03-26 00:02:16 +01:00
Marc MuellerandGitHub 81c34ac952 Fix spelling [docstrings + comments] (#114168) 2024-03-25 11:33:00 +01:00
00ec7f11f0 Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <[email protected]>
2024-03-19 09:01:07 +01:00
J. Nick KostonandGitHub ef0c17749f Use async_create_task in recorder init tests (#113586) 2024-03-16 15:40:50 +01:00
27e844e3bf Add ruff B005, B015, B032 and fix occurrences (#113543)
Co-authored-by: Jan Bouwhuis <[email protected]>
Co-authored-by: J. Nick Koston <[email protected]>
2024-03-15 17:48:37 -10:00
J. Nick KostonandGitHub af6f2a516e Guard against db corruption when renaming entities (#112718) 2024-03-08 11:34:07 -10:00
Marc MuellerandGitHub 7d6251ca08 Add empty line after module docstring [tests q-s] (#112711) 2024-03-08 14:47:22 +01:00
J. Nick KostonandGitHub 235771aaa2 Bump SQLAlchemy to 2.0.28 (#112314) 2024-03-05 12:14:30 -10:00
Marc MuellerandGitHub 2ef2172b01 Convert test helpers to get hass instance to contextmanagers (#109990)
* Convert get_test_home_assistant helper to contextmanager

* Convert async_test_home_assistant helper to contextmanager

* Move timezone reset to async_test_home_assistant helper
2024-02-11 21:23:51 +01:00
Marc MuellerandGitHub 438d3b01b9 Use builtin TimeoutError [o-s] (#109682) 2024-02-05 12:14:37 +01:00
J. Nick KostonandGitHub a22244707b Create an issue when database backups fail because the system runs out of resources (#109020) 2024-01-30 10:23:58 -10:00
J. Nick KostonandGitHub c399cab427 Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
Ville SkyttäandGitHub 24b1e01d71 Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
2023-12-20 23:55:09 +01:00
Erik MontnemeryandGitHub 0dc21504f5 Remove support for excluding attributes in recorder platforms (#100679) 2023-09-24 14:45:06 +02:00
Ville SkyttäandGitHub 34b47a2597 Remove unnnecessary pylint configs from components [m-r]* (#98924) 2023-08-24 00:56:50 +02:00
Marc MuellerandGitHub cd8d6ecd81 Fix recorder DeprecationWarnings (#97738) 2023-08-04 11:32:51 +02:00
J. Nick KostonandGitHub b2e708834f Add slots to the StateMachine class (#95849) 2023-07-05 14:00:37 +02:00
12129e9d21 Update service call return values and error handling (#94657)
* Update return signature of service calls

* Add timeout error handling in websocket api for service calls

* Update recorder tests to remove assertion on service call

* Remove timeout behavior and update callers that depend on it today

* Fix tests

* Add missing else

* await coro directly

* Fix more tests

* Update the intent task to use wait instead of timeout

* Remove script service call limits and limit constants

* Update tests that depend on service call limits

* Use wait instead of wait_for and add test

* Update homeassistant/helpers/intent.py

Co-authored-by: Martin Hjelmare <[email protected]>

---------

Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
2023-06-16 07:01:40 -07:00
2ec1359063 Dynamically size recorder max backlog based on available memory (#90894)
Co-authored-by: Franck Nijhof <[email protected]>
2023-04-18 12:35:49 +02:00
J. Nick KostonandGitHub fdc6cf3472 Continue recording events until final write (#91260) 2023-04-16 09:22:47 -10:00
J. Nick KostonandGitHub 1379ad60c8 Ensure recorder always attempts clean shutdown if recorder thread raises (#91261)
* Ensure recorder run shutdown if the run loop raises

If anything goes wrong with the recorder we should
still try to shutdown cleanly

* tweak

* tests

* tests

* handle migraiton failure

* tweak comment

* naming

* order

* order

* order

* reword

* adjust test

* fixes

* threading

* failure case

* fix test

* have to wait for stop because the task blocks on thread join
2023-04-14 21:03:24 -04:00
epenetandGitHub 2f7c5a56eb Use tmp_path in recorder tests (#91202) 2023-04-11 09:18:16 +02:00
J. Nick KostonandGitHub 49079691d4 Reduce overhead of legacy database columns on new installs (#90246)
* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* not working as expected

* override the type compiler

* override the type compiler

* override the type compiler

* override the type compiler

* Apply suggestions from code review

* pgsql char1

* make entity filter test setup with old schema

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix more dbstate mutations

* add shim for older tests

* split migration tests

* add coverage for purging legacy data

* tweak

* more fixes

* drop some legacy

* fix another test

* fix a few more

* add casts for postgresql in case someone deletes the schema changes table

* dry

* dry

* dry
2023-04-10 10:08:46 -04:00
J. Nick KostonandGitHub 96c5e845e5 Guard against invalid ULIDs in contexts while recording events (#90889) 2023-04-06 10:34:54 +02:00
J. Nick KostonandGitHub 4f1574b859 Prevent overly large event data from being stored in the database (#90747)
This is the same change as #87105 for events
2023-04-04 00:02:49 -04:00
J. Nick KostonandGitHub d49fbc17df Fix recorder attribute excludes not being effective until after startup (#90198)
* Fix attribute excludes not being effective until after startup

fixes #90016

* reduce
2023-03-23 20:52:37 -04:00
J. Nick KostonandGitHub 96225bb287 Rename recorder run_history to table_managers.recorder_runs_manager (#90070) 2023-03-21 18:38:33 -10:00
epenetandGitHub ab4a726e6c Add tmpdir to known fixtures in pylint (#89844) 2023-03-17 10:22:02 +01:00
J. Nick KostonandGitHub f6f3565796 Reduce latency to find stats metadata (#89824) 2023-03-16 19:00:02 -10:00
epenetandGitHub ff8b91aeea Add freezer to known test fixtures in pylint (#89825)
Add freezer to known fixtures in pylint
2023-03-16 22:39:41 -04:00
e379aa23bd Migrate StateAttributes to use a table manager (#89760)
Co-authored-by: Paulus Schoutsen <[email protected]>
2023-03-15 15:26:29 -10:00
J. Nick KostonandGitHub b906d67c1e Fix filtered purge not removing newer events (#89721) 2023-03-14 16:33:19 -10:00
J. Nick KostonandGitHub c41f91be89 Deduplicate entity_id in the states table (#89557) 2023-03-12 10:01:58 -10:00
J. Nick KostonandGitHub 8bd43760b6 Deduplicate event_types in the events table (#89465)
* Deduplicate event_types in the events table

* Deduplicate event_types in the events table

* more fixes

* adjust

* adjust

* fix product

* fix tests

* adjust

* migrate

* migrate

* migrate

* more test fixes

* more test fixes

* fix

* migration test

* adjust

* speed up

* fix index

* fix more tests

* handle db failure

* preload

* tweak

* adjust

* fix stale docs strings, remove dead code

* refactor

* fix slow tests

* coverage

* self join to resolve query performance

* fix typo

* no need for quiet

* no need to drop index already dropped

* remove index that will never be used

* drop index sooner as we no longer use it

* Revert "remove index that will never be used"

This reverts commit 461aad2c52.

* typo
2023-03-11 14:54:55 -05:00
J. Nick KostonandGitHub a9731a7b26 Make the recorder LRU adjustment threadsafe (#88443) 2023-02-19 19:30:08 +01:00
J. Nick KostonandGitHub 9df00bd285 Adjust recorder LRU cache to align with the number of entities (#88350)
* Adjust size of recorder LRU based on number of entities

If there are a large number of entities the cache would
get thrashed as there were more state attributes being
recorded than the size of the cache. This meant we had
to go back to the database to do lookups frequently when
an instance has more than 2048 entities that change
frequently

* add a test

* do not actually record 4096 states

* patch target

* patch target
2023-02-19 00:02:36 -05:00
J. Nick KostonandGitHub 3ca9f3c0d5 Only build the recorder SupportedDialect enum once (#88402)
Every call to dialect_name was creating a new enum object
in the recorder
2023-02-18 20:21:14 -05:00
Erik MontnemeryandGitHub 83e5bf7ae8 Use entity_sources to determine integration in recorder platforms (#88382) 2023-02-18 07:21:41 -06:00
J. Nick KostonandGitHub 289bab6f87 Make recorder platform attribute exclude integration aware (#88357) 2023-02-18 10:08:59 +01:00
epenetandGitHub 185cd61cbd Add type hints to integration tests (recorder) (#88313) 2023-02-17 18:50:09 +01:00
Franck NijhofandGitHub ed79265843 Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
cbaf4764e7 Ensure MySQL tests cleanup connections and raise an exception if they do not (#87767)
Co-authored-by: epenet <[email protected]>
Co-authored-by: Erik <[email protected]>
2023-02-09 16:27:53 -06:00