1
0
mirror of https://github.com/home-assistant/core.git synced 2025-07-03 11:27:05 +00:00

161 Commits

Author SHA1 Message Date
J. Nick Koston
aef266b940
Refactor live history and logbook to avoid unnecessary task creation for recorder sync () 2025-04-19 10:55:11 +02:00
Robert Resch
e3f2f30395
Add circular mean statistics and sensor state class MEASUREMENT_ANGLE ()
* Add circular mean statistics

* fixes

* Add has_circular_mean and fix tests

* Fix mypy

* Rename to MEASUREMENT_ANGLE

* Fix kitchen_sink tests

* Fix sensor tests

* for testing only

* Revert ws command change

* Apply suggestions

* test only

* add custom handling for postgres

* fix recursion limit

* Check if column is already available

* Set default false and not nullable for has_circular_mean

* Proper fix to be backwards compatible

* Fix value is None

* Align with schema

* Remove has_circular_mean from test schemas as it's not required anymore

* fix wrong column type

* Use correct variable to reduce stats

* Add guard that the uom is matching a valid one from the state class

* Add some tests

* Fix tests again

* Use mean_type in StatisticsMetato difference between different mean type algorithms

* Fix leftovers

* Fix kitchen_sink tests

* Fix postgres

* Add circular mean test

* Add mean_type_changed stats issue

* Align the attributes with unit_changed

* Fix mean_type_change stats issue

* Add missing sensor recorder tests

* Add test_statistic_during_period_circular_mean

* Add mean_weight

* Add test_statistic_during_period_hole_circular_mean

* Use seperate migration step to null has_mean

* Typo ARITHMETIC

* Implement requested changes

* Implement requested changes

* Split into 

* Add StatisticMeanType.NONE and forbid that mean_type can be None

* Fix mean_type

* Implement requested changes

* Small leftover of latest StatisticMeanType changes
2025-03-26 13:15:58 +01:00
Erik Montnemery
32f59bfd25
Remove unused constant from recorder () 2025-03-04 11:39:35 +01:00
Erik Montnemery
ff4f4111d0
Minor adjustment of recorder helper () 2025-02-20 16:28:39 +00:00
epenet
d5568ff955
Standardize homeassistant imports in full-CI components ()
Standardize homeassistant imports in components
2025-01-28 13:11:19 -05:00
Ville Skyttä
40eb8b91cc
Adjust to recommended propcache.api import paths () 2025-01-21 10:58:22 +01:00
J. Nick Koston
3c6113e37c
Remove per engine max bind vars () 2025-01-09 22:50:13 +00:00
Erik Montnemery
c901352bef
Add error prints for recorder fatal errors () 2025-01-03 10:01:35 +01:00
Erik Montnemery
cf238cd8f7
Don't start recorder if a database from the future is used () 2025-01-02 18:56:23 +01:00
Erik Montnemery
bb7abd037c
Revert "Revert "Improve recorder history queries ()"" ()
Revert "Revert "Improve recorder history queries ()" ()"

This reverts commit 74e4654c26177909e653921f27f838fd1366adc0.
2024-12-19 11:50:12 +01:00
Erik Montnemery
d22668a166
Don't run recorder data migration on new databases ()
* Don't run recorder data migration on new databases

* Add tests
2024-12-17 20:02:12 +01:00
Erik Montnemery
74e4654c26
Revert "Improve recorder history queries ()" () 2024-12-15 12:28:32 +01:00
Erik Montnemery
ff1702eefa
Remove unnecessary assignment in Recorder._process_state_changed_event_into_session () 2024-12-01 13:40:40 -05:00
Erik Montnemery
598ce1f3b0
Freeze integration setup timeout for recorder during non-live data migration () 2024-12-01 09:17:55 -06:00
Erik Montnemery
381d5453b1
Improve recorder history queries ()
* Improve recorder history queries

* Remove some comments

* Update StatesManager._oldest_ts when adding pending state

* Update after review

* Improve tests

* Improve post-purge logic

* Avoid calling dt_util.utc_to_timestamp in new code

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-11-27 21:12:42 +01:00
Erik Montnemery
db5cb6233c
Correct condition signalling non-live DB migration is in progress () 2024-10-29 12:26:52 -10:00
Erik Montnemery
d8b618f7c3
Remove support for live recorder data migration of context ids () 2024-10-26 07:19:03 +02:00
J. Nick Koston
0f29fd3e10
Switch to using fast cached_property implementation in propcache () 2024-10-03 13:11:02 -05:00
Erik Montnemery
3f1acdc9ec
Make recorder WS command recorder/clear_statistics wait () 2024-10-02 10:43:40 +02:00
Erik Montnemery
2a2af01d12
Make recorder WS command recorder/update_statistics_metadata wait () 2024-10-02 09:56:36 +02:00
Erik Montnemery
dd4f1a0d0f
Simplify recorder statistics_meta_manager () 2024-09-10 21:00:06 +02:00
Erik Montnemery
7fc0e36b2f
Move recorder EntityIDPostMigrationTask to migration ()
* Move recorder EntityIDPostMigrationTask to migration

* Update test
2024-09-04 08:38:46 +02:00
Erik Montnemery
7c223db1d5
Remove recorder PostSchemaMigrationTask ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-03 07:51:27 +02:00
Erik Montnemery
fbfd8c48aa
Remove unused event from recorder () 2024-09-02 13:33:51 +02:00
J. Nick Koston
6f66f37fc7
Shutdown database engine before waiting for executor shutdown ()
* Close database connection before stopping the executor

related issue 

* Close database connection before waiting for database executor to finish

related issue 

* fix test

* fix

* drop unused arg

* Revert "drop unused arg"

This reverts commit 8a9fe6a24a614d7fda2058248f653fa400a5a252.

* docstring

* comment
2024-08-22 16:47:22 +02:00
Erik Montnemery
5d3c57ecfe
Freeze integration setup timeout for recorder during non-live migration () 2024-07-22 18:48:55 -05:00
Erik Montnemery
3dc36cf068
Improve error handling when creating new SQLite database ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-07-22 14:16:11 -05:00
Erik Montnemery
20fc5233a1
Add recorder data migrator class to clean up states table () 2024-07-22 13:04:01 -05:00
Erik Montnemery
76cd53a864
Improve error handling when recorder schema migration fails () 2024-07-22 18:55:12 +02:00
Erik Montnemery
b14e8d1609
Remove SchemaValidationStatus.valid () 2024-07-22 17:33:13 +02:00
Erik Montnemery
e8b88557ee
Refactor recorder schema migration ()
* Refactor recorder schema migration

* Simplify

* Remove unused imports

* Refactor _migrate_schema according to review comments

* Add comment
2024-07-22 16:53:54 +02:00
Erik Montnemery
cbe94c4706
Fix typo in recorder persistent notification () 2024-07-22 12:02:17 +02:00
Erik Montnemery
2f47312eeb
Fix recorder setup hanging if non live schema migration fails () 2024-07-20 13:10:23 +02:00
Erik Montnemery
436a38c1d2
Revert "Fix recorder setup hanging if non live schema migration fails" () 2024-07-20 12:29:08 +02:00
Erik Montnemery
153b69c971
Fix recorder setup hanging if non live schema migration fails () 2024-07-20 11:17:40 +02:00
Erik Montnemery
9970b7eece
Refactor recorder data migration ()
* Refactor recorder data migration

* Fix stale docstrings

* Don't store a session object in BaseRunTimeMigration instances

* Simplify logic in EntityIDMigration.migration_done

* Fix tests
2024-07-16 21:50:19 +02:00
J. Nick Koston
73f6e3c07b
Narrow sqlite database corruption check to ensure disk image is malformed ()
* Narrow sqlite database corruption check to ensure disk image is malformed

The database corruption check would also replace the database when it
locked externally instead of only when its malformed.

This was discovered in https://github.com/home-assistant/core/issues/121909#issuecomment-2227409124
when a user did a manual index creation while HA was online

* tweak

* tweak

* fix

* fix
2024-07-14 23:23:07 +02:00
J. Nick Koston
19d2d023ab
Ensure states table rebuild still happens if the event_id index was removed ()
* Ensure states table rebuild still happens if the event_id index was removed

If ix_states_event_id was removed by the foreign key still
exists, the states table would not get rebuilt. This should
not happen under normal circumstances and seems to only be
possible if the index was removed manually or Home
Assistant was restarted forcefully in the middle
of a previous migration from years ago.

* cover

* fix tests

* mysql wont allow at that point but thats ok as long as its gone at the end
2024-07-14 23:20:52 +02:00
J. Nick Koston
43596f22a4
Fix recorder max backlog calculation being too small () 2024-07-11 09:09:35 +02:00
J. Nick Koston
c81d5a1ac2
Handle empty entity_id in the recorder filter ()
fixes 
2024-07-10 09:53:38 -05:00
Erik Montnemery
6eeb70151d
Use BIGINT SQL type for ID columns () 2024-07-05 10:42:39 -05:00
Erik Montnemery
61f1c8d963
Fix leak of SQLAlchemy engine objects in recorder () 2024-07-03 12:17:52 -05:00
Erik Montnemery
e26b4554e6
Improve logic when retrying establishing database connection () 2024-07-03 16:22:21 +02:00
Marc Mueller
b798d76706
Update mypy-dev to 1.11.0a9 () 2024-06-24 09:57:15 +02:00
J. Nick Koston
9082dc2a79
Reduce recorder overhead when entity filter is empty () 2024-06-14 08:43:51 +02:00
J. Nick Koston
0888233f06
Make Recorder dialect_name a cached_property () 2024-05-29 09:23:40 +02:00
Sid
c2b3bf3fb9
Enable Ruff RET502 () 2024-05-21 22:19:33 +02:00
Marc Mueller
26a599ad11
Use PEP 695 for function annotations (1) () 2024-05-18 11:45:54 +02:00
Sid
2cc916db6d
Replace pylint broad-except with Ruff BLE001 () 2024-05-07 14:00:27 +02:00
J. Nick Koston
6339c63176
Improve recorder and worker thread matching in RecorderPool ()
* 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