Commit graph

843 commits

Author SHA1 Message Date
Ville Skyttä
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
J. Nick Koston
5c503683b7
Bump lru-dict to 1.3.0 (#105914)
* Bump lru-dict to 1.3.0

changelog: https://github.com/amitdev/lru-dict/compare/v1.2.0...v1.3.0

* fix typing

* quote types

* quote types
2023-12-18 00:16:31 +01:00
Alex Hermann
bdef0ba6e5
Significantly improve performance for some cases of the history start time state query (#99450)
* recorder: Apply filter in the outer query too

Function _get_start_time_state_for_entities_stmt() produced a query which
is dead-slow in my installation. On analysis, the outer query produced
millions of rows which had to be joined to the subquery. The subquery has
a filter which would eliminate almost all of the outer rows.

To speed up the query, apply the same filter to the outer query, so way
less rows have to be joined.

This reduced the query time on my system from more than half an hour to
mere milliseconds.

* lint

* merge filter

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-11-28 16:23:49 -06:00
Aarni Koskela
706add4a57
Switch formatting from black to ruff-format (#102893)
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 (#104296) 2023-11-24 11:46:02 +01:00
Marc Mueller
a70ec64408
Update mypy to 1.7.0 (#103800) 2023-11-11 23:31:04 +01:00
J. Nick Koston
fd8caaf846
Bump SQLAlchemy to 2.0.23 (#103313) 2023-11-03 11:10:08 -05:00
J. Nick Koston
268425b5e3
Recover from previously failed statistics migrations (#101781)
* 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
3cfcffc6f2
Bump fnv-hash-fast to 0.5.0 (#102271) 2023-10-20 16:49:40 +02:00
J. Nick Koston
93f10cdce8
Move event permissions out of the websocket api into auth (#101975) 2023-10-15 23:14:19 +02:00
J. Nick Koston
e427fc511b
Bump SQLAlchemy to 2.0.22 (#102033) 2023-10-15 06:14:51 -10:00
J. Nick Koston
c6ed022cce
Fix compiling missing statistics losing rows (#101616) 2023-10-08 19:43:00 +02:00
J. Nick Koston
48a23798d0
Fix caching of latest short term stats after insertion of external stats (#101490) 2023-10-06 09:18:05 +02:00
J. Nick Koston
da1d5fc862
Increase max bind vars based on database version (#101464) 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 (#100535) 2023-09-26 09:57:59 -05:00
Erik Montnemery
0dc21504f5
Remove support for excluding attributes in recorder platforms (#100679) 2023-09-24 14:45:06 +02:00
Erik Montnemery
fbcc5318c5
Move attributes to be excluded from recording to entity classes (#100239)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-09-20 18:09:12 +02:00
J. Nick Koston
6f8734167f
Bump SQLAlchemy to 2.0.21 (#99745) 2023-09-20 16:19:53 +02:00
Erik Montnemery
51576b7214
Improve typing of entity.entity_sources (#99407)
* Improve typing of entity.entity_sources

* Calculate entity info source when generating WS response

* Adjust typing

* Update tests
2023-09-12 20:41:26 +02:00
J. Nick Koston
50382a609c
Create recorder futures with loop.create_future() (#100049) 2023-09-10 11:24:57 -05:00
Erik Montnemery
7168e71860
Log unexpected exceptions causing recorder shutdown (#99445) 2023-09-02 09:51:06 -05:00
Erik Montnemery
7e7cb15d5b
Revert "Allows defining list of attributes excluded from history in manifest.json" (#99300)
Revert "Allows defining list of attributes excluded from history in manifest.json (#99283)"

This reverts commit 0366e14630.
2023-08-30 08:26:26 +02:00
Erik Montnemery
0366e14630
Allows defining list of attributes excluded from history in manifest.json (#99283)
* Move list of attributes excluded from history to manifest.json

* Address comments
2023-08-29 20:14:33 +02:00
J. Nick Koston
6992ea9af0
Bump fnv-hash-fast to 0.4.1 (#99135) 2023-08-27 10:08:21 -05:00
Ville Skyttä
c287bd1a3b
Remove pylint configs flagged by useless-suppression (#99081) 2023-08-26 17:46:03 +03:00
Ville Skyttä
34b47a2597
Remove unnnecessary pylint configs from components [m-r]* (#98924) 2023-08-24 00:56:50 +02:00
Ville Skyttä
3094991236
Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Marc Mueller
a9ade1f84d
Use asyncio.timeout [core] (#98447) 2023-08-15 08:36:05 -05:00
J. Nick Koston
5cc72814c9
Bump fnv-hash-fast to 0.4.0 (#97160) 2023-07-24 20:34:46 +02:00
Franck Nijhof
30058297cf
Migrate backported StrEnum to built-in StrEnum (#97101) 2023-07-23 23:19:24 +02:00
Franck Nijhof
86708b5590
Update ruff to v0.0.280 (#97102) 2023-07-23 22:00:26 +02:00
Marc Mueller
77f38e33e5
Import names from typing instead of typing_extensions [3.11] (#97065) 2023-07-22 17:03:44 -05:00
Paulus Schoutsen
7859be6481
Add deduplicate translations script (#96384)
* Add deduplicate script

* Fix forecast_solar incorrect key with space

* Fix utf-8

* Do not create references to other arbitrary other integrations

* Add commented code to only allow applying to referencing integrations

* Tweak

* Bug fix

* Add command line arg for limit reference

* never suggest to update common keys

* Output of script

* Apply suggestions from code review

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>

---------

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
2023-07-13 11:52:50 -04:00
Joost Lekkerkerker
b367c95c81
Add more common translations (#96429)
* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations
2023-07-12 22:00:05 -04:00
Franck Nijhof
d3eda12af4
Migrate recorder services to support translations (#96409)
Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
2023-07-12 17:28:05 +02:00
J. Nick Koston
b2e708834f
Add slots to the StateMachine class (#95849) 2023-07-05 14:00:37 +02:00
Franck Nijhof
3e85a29b86
Move overlapping pylint rules to ruff, disable mypy overlap (#94359) 2023-06-27 17:42:46 +02:00
Erik Montnemery
863b948e7c
Correct calls to super class in RecorderPool (#94923) 2023-06-20 23:26:37 +02:00
Franck Nijhof
c3936e6f14
Replace isort with ruff (#94302) 2023-06-08 23:43:56 +02:00
Ville Skyttä
ca936d0b38
Replace bandit with ruff (#93200) 2023-06-08 22:46:04 +02:00
J. Nick Koston
7995d3777a
Fix package names to match pypi index metadata (#93883)
* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* Fix package names to match pypi index metadata

* uses _

* uses -

* fix metadata
2023-05-31 21:12:53 -04:00
J. Nick Koston
493d78f070
Avoid dict comp in statistic_during_period if there is no conversion (#93699) 2023-05-29 20:59:15 -04:00
J. Nick Koston
2f1f32f0bb
Make unit converter use a factory to avoid looking up the ratios each conversion (#93706) 2023-05-29 20:50:40 +02:00
J. Nick Koston
560e744f1e
Reduce overhead to filter entities in the recorder (#93656)
* Reduce overhead to filter entities in the recorder

* fix type
2023-05-27 19:52:42 -04:00
J. Nick Koston
f251c464e2
Fix history start time state returning None with some postgresql versions (#93555)
* Add additional coverage to history websocket api

related issue #93258

* Add additional coverage to history websocket api

related issue #93258

* Fix results when union query ends up at the end instead of front

* Apply suggestions from code review

* resort

* zero instead

* fix exception

* fix tests
2023-05-25 22:18:19 -04:00
J. Nick Koston
d9b43fc43f
Significantly speed up recorder event listener (#93532)
* Significantly speed up recorder event listener

This code is called every time an event happens since it
subscribes to all events. Its our most frequently called
listener out of the box.

It used to have a seperate filter function but it was
later combined after core had some previous refactoring.

It was never optimized after that happened.

This change reduces the run time by ~70%

* decruft
2023-05-25 21:44:12 -04:00
J. Nick Koston
f09abb0f2e
Fix race in tracking pending writes in recorder (#93414) 2023-05-23 21:47:31 +02:00
J. Nick Koston
cbee514c2a
Bump sqlalchemy to 2.0.15 (#93293) 2023-05-20 14:26:33 -05:00
J. Nick Koston
809f394ff5
Bump sqlalchemy to 2.0.13 (#92936) 2023-05-12 04:37:16 +09:00
Erik Montnemery
c1f716487c
Include data for entire periods in response to recorder/statistics_during_period (#92848)
* Include data for entire periods in response to recorder/statistics_during_period

* Break out function for calculating the end of the month
2023-05-11 11:28:33 +02:00