Commit Graph

594 Commits (7a9849771098e66a6ed33771f92adcb10d7a3b29)

Author SHA1 Message Date
Erik Montnemery 1a714276cc
Remove support for live recorder data migration of entity IDs (#131952) 2024-12-03 14:43:33 -06:00
Erik Montnemery cf0ee63507
Simplify recorder RecorderRunsManager (#131785) 2024-12-01 11:26:29 -06:00
J. Nick Koston 8878d0f0e1
Reduce time syscalls needed to insert new statistics (#131984) 2024-12-01 08:55:07 -06:00
Erik Montnemery bbce183faf
Deprecate dt_util.utc_to_timestamp (#131787) 2024-11-28 17:00:20 +01:00
Erik Montnemery d9832f8c3a
Rename constant in tests/components/recorder/test_migration_from_schema_32.py (#131819) 2024-11-28 13:26:58 +01:00
Erik Montnemery 381d5453b1
Improve recorder history queries (#131702)
* 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 44f90dca0c
Fix logic for purge of recorder runs (#130378)
* Fix logic for purge of recorder runs

* Make test more explicit

* Explicitly don't remove unclosed recorder runs in purge
2024-11-26 07:47:47 +01:00
Davin Kevin f42386de44
Prevent endless loop in recorder when using a filter and there are no more states to purge (#126149)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-11-21 20:50:49 +01:00
Michael Arthur d8549409f7
Area units and conversion between metric and US (#123563)
* area conversions

* start work on tests

* add number device class

* update unit conversions to utilise distance constants

* add area unit

* update test unit system

* update device condition and trigger

* update statistic unit converters

* further tests work WIP

* update test unit system

* add missing string translations

* fix websocket tests

* add deprecated notice

* add more missing strings and missing initialisation of unit system

* adjust icon and remove strings from scrape and random

* Fix acre to meters conversion

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Tidy up valid units

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* fix ordering of area

* update order alphabetically

* fix broken test

* update test_init

* Update homeassistant/const.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* remove deprecated unit and fix alphabetical order

* change deprecation and add tests, change to millimeter conversion for inches

* fix order

* re-order defs alphabetically

* add measurement as well

* update icons

* fix up Deprecation of area square meters

* Update core integrations to UnitOfArea

* update test recorder tests

* unit system tests in alphabetical

* update snapshot

* rebuild

* revert alphabetization of functions

* other revert of alphabetical order

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-11-21 16:10:44 +01:00
Erik Montnemery db5cb6233c
Correct condition signalling non-live DB migration is in progress (#129464) 2024-10-29 12:26:52 -10:00
Marc Mueller 2de161ce0e
Fix mariadb recorder tests for Python 3.13 (#129303) 2024-10-29 09:17:47 +01:00
Erik Montnemery d8b618f7c3
Remove support for live recorder data migration of context ids (#125309) 2024-10-26 07:19:03 +02:00
J. Nick Koston db494de809
Restore __slots__ to core objects (#127441) 2024-10-03 22:23:47 +02:00
Erik Montnemery 3f1acdc9ec
Make recorder WS command recorder/clear_statistics wait (#127120) 2024-10-02 10:43:40 +02:00
Erik Montnemery 2a2af01d12
Make recorder WS command recorder/update_statistics_metadata wait (#127179) 2024-10-02 09:56:36 +02:00
J. Nick Koston e87542e091
Fix removing nulls when encoding events for PostgreSQL (#127053) 2024-09-30 09:01:41 +02:00
Erik Montnemery 66ab90b518
Add EntityIDPostMigration data migrator class (#125307) 2024-09-27 14:58:34 +02:00
Erik Montnemery 771575cfc5
Make statistics validation create issue registry issues (#122595)
* Make statistics validation create issue registry issues

* Disable creating issue about outdated MariaDB version in tests

* Use call_soon_threadsafe instead of run_callback_threadsafe

* Update tests

* Fix flapping test

* Disable creating issue about outdated SQLite version in tests

* Implement agreed changes

* Add translation strings for issue titles

* Update test
2024-09-25 11:11:11 +02:00
Erik Montnemery 161f37bb98
Add tests which directly test the recorder job wrappers (#125338) 2024-09-24 23:00:00 +02:00
Erik Montnemery ba5f1ac2a9
Bump version of recorder context ID data migrators (#125293) 2024-09-24 13:45:37 +02:00
G Johansson 93aade6e8e
Change lock state to an enum (#126379)
* Add new LockState enum for lock states

* Add rest

* Fix insteon tests

* Fix mqtt tests

* Fix tesla_fleet

* Revert back ST_STATE_LOCKED

* Add back constant
2024-09-24 12:30:50 +02:00
Erik Montnemery bde92b34dd
Remove recorder history queries for database schemas < 31 (#125652) 2024-09-10 19:26:19 +02:00
Erik Montnemery 99122fcb78
Remove recorder history queries for database schemas < 25 (#125649) 2024-09-10 12:43:08 +02:00
Erik Montnemery 2a1df2063d
Separate recorder test fixtures disabling context id migration (#125324)
* Separate recorder test fixtures disabling context id migration

* Fix test
2024-09-09 08:16:30 +02:00
Erik Montnemery 0ca0836e83
Correct check for removed index in recorder test (#125323) 2024-09-06 07:21:41 +02:00
Erik Montnemery 8fd691be69
Teach recorder data migrator base class to remove index (#125168)
* Teach recorder data migrator base class to remove index

* Fix tests
2024-09-04 09:52:41 +02:00
Erik Montnemery 7fc0e36b2f
Move recorder EntityIDPostMigrationTask to migration (#125136)
* Move recorder EntityIDPostMigrationTask to migration

* Update test
2024-09-04 08:38:46 +02:00
Erik Montnemery d8382c6de2
Improve recorder tests to check indices are removed (#125164) 2024-09-03 22:56:27 +02:00
Erik Montnemery cc3d059783
Refactor recorder EventIDPostMigration data migrator (#125126) 2024-09-03 22:37:50 +02:00
Erik Montnemery 1dcae0c0a6
Improve some comments in recorder tests (#125118) 2024-09-03 17:04:08 +02:00
Erik Montnemery 606524f9e7
Test string timestamps are wiped after migration to schema version 32 (#125091)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-02 21:33:35 +02:00
Erik Montnemery 0b14f0a379
Add test of statistics timestamp migration (#125100) 2024-09-02 09:13:26 -10:00
Erik Montnemery 9f558d13e6
Correct start version in recorder schema migration tests (#125090)
* Correct start version in recorder schema migration tests

* Remove default from states.last_updated_ts
2024-09-02 19:32:01 +02:00
Erik Montnemery b9aaba0432
Prevent duplicating constraints during schema migration (#124616) 2024-08-26 08:35:54 -10:00
J. Nick Koston 6f66f37fc7
Shutdown database engine before waiting for executor shutdown (#117339)
* Close database connection before stopping the executor

related issue #117004

* Close database connection before waiting for database executor to finish

related issue #117004

* fix test

* fix

* drop unused arg

* Revert "drop unused arg"

This reverts commit 8a9fe6a24a.

* docstring

* comment
2024-08-22 16:47:22 +02:00
epenet c76d68503a
Add missing hass type hint in history and recorder tests (#124204) 2024-08-19 15:41:09 +02:00
Erik Montnemery 06d1bbc20f
Update recorder tests to async (#124161) 2024-08-18 21:14:41 +02:00
Erik Montnemery ce2ffde22e
Update sensor recorder tests to async (#124061) 2024-08-18 13:20:58 -05:00
Erik Montnemery a7bca9bcea
Use BIGINT SQL type for ID columns (#123973)
Redo recorder ID migration from INT to BIGINT
2024-08-17 11:01:14 +02:00
epenet 66a8733333
Add missing return type in test __init__ method (part 4) (#123947) 2024-08-16 10:26:12 +02:00
Erik Montnemery 64a68b17f4
Simplify recorder.migration._drop_foreign_key_constraints (#123968) 2024-08-15 11:58:52 -05:00
Erik Montnemery f72d9a2c02
Raise on database error in recorder.migration._modify_columns (#123642)
* Raise on database error in recorder.migration._modify_columns

* Improve test coverage
2024-08-15 14:46:23 +02:00
Erik Montnemery 26e80cec3d
Deduplicate some recorder migration tests (#123972) 2024-08-15 11:09:24 +02:00
Erik Montnemery 81c4bb5f72
Fix flaky recorder migration tests (#123971) 2024-08-15 10:32:40 +02:00
Erik Montnemery 667414a457
Raise on database error in recorder.migration._drop_foreign_key_constraints (#123645)
* Raise on database error in recorder.migration._drop_foreign_key_constraints

* Fix test

* Fix test

* Revert "Fix test"

This reverts commit 940b8cb506e912826d43d09d7697c10888bdf685.

* Update test

* Improve test coverage

* Disable test for SQLite
2024-08-15 08:25:18 +02:00
Erik Montnemery e6ed3c8c5c
Raise on database error in recorder.migration function (#123644)
* Raise on database error in recorder.migration._update_states_table_with_foreign_key_options

* Improve test coverage

* Fix test

* Fix test
2024-08-14 22:37:23 +02:00
epenet 3e967700fd
Add missing return type in test __init__ method (part 2) (#123939)
* Add missing return type in test __init__ method (part 2)

* Adjust

* One more

* One more

* More
2024-08-14 17:59:15 +02:00
Erik Montnemery e050d187c4
Clarify SQLite can't drop foreign key constraints (#123898) 2024-08-14 07:04:53 -05:00
Erik Montnemery 80f5683cd6
Raise on database error in recorder.migration._add_constraint (#123646)
* Raise on database error in recorder.migration._add_constraint

* Fix test
2024-08-14 13:59:06 +02:00
Erik Montnemery b7bbc938d3
Drop violating rows before adding foreign constraints in DB schema 44 migration (#123454)
* Drop violating rows before adding foreign constraints

* Don't delete rows with null-references

* Only delete rows when integrityerror is caught

* Move restore of dropped foreign key constraints to a separate migration step

* Use aliases for tables

* Update homeassistant/components/recorder/migration.py

* Update test

* Don't use alias for table we're deleting from, improve test

* Fix MySQL

* Update instead of deleting in case of self references

* Improve log messages

* Batch updates

* Add workaround for unsupported LIMIT in PostgreSQL

* Simplify

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-08-14 09:31:37 +02:00