Commit graph

456 commits

Author SHA1 Message Date
Sid
d5f883fbf0
Unignore Ruff PLR in tests ()
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Sid
aec7a67a58
Unignore Ruff PLE, PLW in tests ()
* Unignore Ruff PLE, PLW in tests

* fix tests
2024-03-29 23:58:30 +01:00
Erik Montnemery
4d7a434254
Don't access States.last_reported_ts before it's added () 2024-03-28 00:44:01 +01:00
Erik Montnemery
a3059fe504
Record state.last_reported ()
* Record state.last_reported

* Include last_reported in parts of the history API

* Use a bulk update

* fix refactoring error

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-27 12:48:06 +01:00
Joost Lekkerkerker
6bb4e7d62c
Bump ruff to 0.3.4 ()
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Marc Mueller
81c34ac952
Fix spelling [docstrings + comments] () 2024-03-25 11:33:00 +01:00
Erik Montnemery
d31124d5d4
Avoid creating unneeded Context and Event objects when firing events ()
* Avoid creating unneeded Context and Event objects when firing events

* Add test

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-20 09:40:06 +01:00
J. Nick Koston
06f356a038
Avoid expensive db queries at startup to check if data is migrated () 2024-03-19 15:27:40 -10:00
Sid
00ec7f11f0
Enable Ruff rule PT007 ()
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
Sid
82a60fe8ad
Enable Ruff RSE () 2024-03-18 00:40:38 +01:00
Sid
d5fd005db8
Add ruff rule PIE808 () 2024-03-17 09:56:26 +01:00
Sid
0b9c9aff62
Add ruff rules PIE790, PIE794, PIE807, PIE810 () 2024-03-16 11:04:58 -10:00
J. Nick Koston
ef0c17749f
Use async_create_task in recorder init tests () 2024-03-16 15:40:50 +01:00
Sid
27e844e3bf
Add ruff B005, B015, B032 and fix occurrences ()
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-15 17:48:37 -10:00
soonsouth
cfc2f17f35
Remove repetitive words in comments and docstrings ()
chore: remove repetitive words

Signed-off-by: soonsouth <cuibuwei@163.com>
2024-03-15 18:11:12 +01:00
Joost Lekkerkerker
77917506bb
Improve lists in integrations [R-S] ()
* Improve lists in integrations [R-S]

* Fix

* Fix
2024-03-13 21:55:00 +01:00
J. Nick Koston
af6f2a516e
Guard against db corruption when renaming entities () 2024-03-08 11:34:07 -10:00
Marc Mueller
32f3f46542
Add empty line after module docstring (2) [tests.components] () 2024-03-08 19:16:21 +01:00
Marc Mueller
7d6251ca08
Add empty line after module docstring [tests q-s] () 2024-03-08 14:47:22 +01:00
J. Nick Koston
235771aaa2
Bump SQLAlchemy to 2.0.28 () 2024-03-05 12:14:30 -10:00
Joakim Sørensen
f622ddef47
Move backup/* WS commands to the backup integration ()
Revert "Revert "Move backup/* WS commands to the backup integration" ()"

This reverts commit 8f83426895.
2024-02-27 11:56:07 -05:00
Joakim Sørensen
8f83426895
Revert "Move backup/* WS commands to the backup integration" ()
Revert "Move backup/* WS commands to the backup integration ()"

This reverts commit ec4e6c3a74.
2024-02-22 16:08:30 +01:00
Joakim Sørensen
ec4e6c3a74
Move backup/* WS commands to the backup integration ()
* Move backup/* WS commands to the backup integration

* Call correct command

* Use debug for logging

* Remove assertion of hass.data for setup test

* parametrize token fixture
2024-02-22 10:25:38 +01:00
J. Nick Koston
f9dc92a9a0
Fix recorder ws_info blocking the event loop ()
* Fix recorder ws_info blocking the event loop

Fixes
```
2024-02-15 06:37:55.423 WARNING (MainThread) [asyncio] Executing <Task pending name=websocket_api.async:ws_info coro=<_handle_async_response() running at /usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py:26> wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()] created at /usr/local/lib/python3.12/asyncio/tasks.py:712> cb=[set.remove()] created at /usr/src/homeassistant/homeassistant/core.py:653> took 0.332 seconds
```

* no instance did not actually work
2024-02-16 15:11:09 +01:00
Marc Mueller
2ef2172b01
Convert test helpers to get hass instance to contextmanagers ()
* 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 Mueller
438d3b01b9
Use builtin TimeoutError [o-s] () 2024-02-05 12:14:37 +01:00
Erik Montnemery
1f466e737e
Use send_json_auto_id in recorder tests () 2024-02-02 09:34:43 +01:00
J. Nick Koston
67e6febde4
Ensure the purge entities service cleans up the states_meta table () 2024-02-02 09:32:17 +01:00
J. Nick Koston
a22244707b
Create an issue when database backups fail because the system runs out of resources () 2024-01-30 10:23:58 -10:00
Marc Mueller
030727b078
Remove deprecated event_loop fixtures in tests () 2024-01-29 14:24:58 +01:00
J. Nick Koston
c399cab427
Small speed up to checking core state () 2024-01-18 08:41:32 -10:00
J. Nick Koston
15384f4661
Remove unused entity_sources argument from shared_attrs_bytes_from_event () 2024-01-17 08:45:04 -05:00
J. Nick Koston
acf78664e2
Reduce overhead to compile statistics ()
* Reduce overhead to compile statistics

statistics uses LazyState for compatibility with State when pulling
data from the database.

After the previous round of refactoring to modern history, the setters
are never called and can be removed.

* reduce
2024-01-07 22:36:49 -05:00
J. Nick Koston
d8c6534aff
Refactor recorder for common event case ()
Almost 99% of items that are put into the recorder queue are
Events. Avoid wrapping them in tasks since we have to unwrap
them right away and its must faster to check for both RecorderTask
and Events since events are the common case.
2024-01-07 22:31:40 -05:00
Ville Skyttä
24b1e01d71
Update Ruff to 0.1.8, avoid linter/formatter conflicts ()
* 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
Aarni Koskela
706add4a57
Switch formatting from black to ruff-format ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
J. Nick Koston
9ed745638d
Chunk purging attributes and data ids for old SQLite versions () 2023-11-24 11:46:02 +01:00
J. Nick Koston
268425b5e3
Recover from previously failed statistics migrations ()
* Handle statistics columns being unmigrated from previous downgrades

If the user downgraded HA from 2023.3.x to an older version without
restoring the database and they upgrade again with the same database
they will have unmigrated statistics columns since we only migrate them
once.

As its expensive to check, we do not want to check every time
at startup, so we will only do this one more time since the
risk that someone will downgrade to an older version is very
low at this point.

* add guard to sqlite to prevent re-migrate

* test

* move test to insert with old schema

* use helper

* normalize timestamps

* remove

* add check

* add fallback migration

* add fallback migration

* commit

* remove useless logging

* remove useless logging

* do the other columns at the same time

* coverage

* dry

* comment

* Update tests/components/recorder/test_migration_from_schema_32.py
2023-10-22 23:34:43 -04:00
J. Nick Koston
27b5a9e074
Reduce number of test states in big purge test to fix CI () 2023-10-20 08:09:59 -10:00
J. Nick Koston
c6ed022cce
Fix compiling missing statistics losing rows () 2023-10-08 19:43:00 +02:00
J. Nick Koston
48a23798d0
Fix caching of latest short term stats after insertion of external stats () 2023-10-06 09:18:05 +02:00
J. Nick Koston
da1d5fc862
Increase max bind vars based on database version () 2023-10-06 07:59:38 +02:00
J. Nick Koston
c9a55c7f84
Cache the latest short term stat id for each metadata_id on each run () 2023-09-26 09:57:59 -05:00
Erik Montnemery
0dc21504f5
Remove support for excluding attributes in recorder platforms () 2023-09-24 14:45:06 +02:00
J. Nick Koston
6f8734167f
Bump SQLAlchemy to 2.0.21 () 2023-09-20 16:19:53 +02:00
Ville Skyttä
9da192c752
Avoid use of datetime.utc* methods deprecated in Python 3.12 ()
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2023-08-24 16:38:22 +02:00
Ville Skyttä
34b47a2597
Remove unnnecessary pylint configs from components [m-r]* () 2023-08-24 00:56:50 +02:00
Ville Skyttä
2399cd283a
Python 3.10 support cleanups () 2023-08-21 19:14:07 +02:00
Marc Mueller
cd8d6ecd81
Fix recorder DeprecationWarnings () 2023-08-04 11:32:51 +02:00
Marc Mueller
fe0fe19be9
Use datetime.UTC alias [3.11] () 2023-07-22 17:05:11 -05:00