Commit Graph

209 Commits (6cc2b1e10a14e69643dae8e4224acbd7a02ed0df)

Author SHA1 Message Date
J. Nick Koston ca5ed274cb
Deprecate calling async_listen and async_listen_once with run_immediately (#115169) 2024-04-08 10:07:54 -10:00
Marc Mueller a0e6fd6ec5
Add improved typing for event fire and listen methods (#114906)
* Add EventType implementation

* Update integrations for EventType

* Change state_changed to EventType

* Fix tests

* Remove runtime impact

* Add tests

* Move to stub file

* Apply pre-commit to stub files

* Fix ruff PYI checks

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-04-07 13:28:24 -10:00
Sid 0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
Marc Mueller 0f03079065
Update import for EventStateChangedData [i-z] (#114900) 2024-04-04 11:48:29 -10:00
Marc Mueller 816ce116bf
Remove unnecessary functools.cached_property backport (#114239) 2024-04-04 11:24:26 +02:00
J. Nick Koston 1e54595084
Use faster time compare in history and live logbook (#113897) 2024-03-20 19:40:23 -04:00
J. Nick Koston 32c64855b2
Fix duplicate events in live logbook (#113828) 2024-03-19 09:17:23 -10:00
J. Nick Koston 8b9a8a33f4
Start live history/logbook with eager tasks (#113779) 2024-03-18 21:00:51 -10:00
Sid 6ee273a548
Clean up unneeded ruff noqa directives (#113616) 2024-03-16 09:48:37 -10:00
Joost Lekkerkerker a3a1647256
Add service icons to Logbook (#113324) 2024-03-14 13:52:27 +01:00
Joost Lekkerkerker 595d07f1c6
Improve lists in integrations [L-M] (#113227)
* Improve lists in integrations [L-M]

* Update homeassistant/components/mailbox/__init__.py

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>

* Fix

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-03-13 21:28:21 +01:00
Marc Mueller de886d8c49
Update EventBus listen type signatures (#112760) 2024-03-08 21:57:23 +01:00
Marc Mueller 84c44c1835
Replace EventType with Event [l-s] (#112741) 2024-03-08 19:37:18 +01:00
Paulus Schoutsen f416d67d21
Remove built-in support for import_executor in manifest (#112725) 2024-03-08 12:02:32 -05:00
Marc Mueller 59a6035d3f
Add empty line after module docstring [j-m] (#112700) 2024-03-08 09:01:29 -05:00
Marc Mueller d7e7dc96cc
Make Event data generic (#111955) 2024-03-08 13:46:16 +01:00
Marc Mueller 8ca127df2a
Use KEY_HASS [h-z] (#112610) 2024-03-07 18:03:44 +01:00
J. Nick Koston 581a4f82b2
Avoid importing counter and proximity integrations in logbook (#112528) 2024-03-06 11:46:38 -10:00
J. Nick Koston 94224c4c73
Import logbook in the executor to avoid blocking the event loop (#111807)
This one is likely because of all the sqlalchemy object construction
for the queries

`Component logbook import took 0.245 seconds (loaded_executor=False)`
2024-02-29 10:36:54 -05:00
Franck Nijhof 1c55ba0cb2
Use covariant for fire event data type (#110843) 2024-02-18 13:21:55 +01:00
J. Nick Koston 0d4c82b54d
Convert Integration platforms processors where nothing is awaited to callbacks (#110825)
Convert Integration platforms processors where nothing is awaited callbacks
2024-02-17 20:49:47 -05:00
J. Nick Koston f73431ac06
Switch utc_to_timestamp to .timestamp() where possible (#109729)
* Switch utc_to_timestamp to .timestamp()

.timestamp() is faster now in newer cpython

```
from homeassistant.util.dt import utc_to_timestamp, utcnow
import timeit
now = utcnow()
print(timeit.timeit('utc_to_timestamp(now)',globals={"now":now,"utc_to_timestamp":utc_to_timestamp}))
print(timeit.timeit('now.timestamp()',globals={"now":now}))
```

utc_to_timestamp = 0.18721245788037777
timestamp = 0.11421508435159922

* compat

* revert

* revert

* revert

* revert

* revert
2024-02-05 23:04:52 +01:00
J. Nick Koston 5dac5d5c7e
Refactor logbook helpers to reduce splits and lookups (#108933)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-01-26 20:07:24 -10:00
J. Nick Koston 60ab360fe7
Avoid bytes to string to bytes conversion in websocket api (#108139) 2024-01-16 21:37:34 +01:00
J. Nick Koston 3d595fff13
Avoid duplicate timestamp conversions for websocket api and recorder (#108144)
* Avoid duplicate timestamp conversions for websocket api and recorder

We convert the time from datetime to timestamps one per
open websocket connection and the recorder for every
state update. Only do the conversion once since its
~30% of the cost of building the state diff

* more

* two more

* two more in live history
2024-01-16 14:05:01 +01:00
J. Nick Koston bc2738c3a1
Avoid entity registry check in live logbook on each state update (#107622)
Avoid entity registry fetch in live logbook

There is no need to check the entity registry for the
state class since we already have the state
2024-01-13 21:04:04 -05:00
J. Nick Koston 0b9992260a
Improve logbook context augment performance (#106926)
Makes LazyEventPartialState a bit lazier since almost all the
properties are never called.
2024-01-07 22:35:28 -05:00
steffenrapp 0b9242f809
Add translatable title to logbook (#106810) 2024-01-02 13:30:04 +01:00
Marc Mueller a70ec64408
Update mypy to 1.7.0 (#103800) 2023-11-11 23:31:04 +01:00
J. Nick Koston 8b30a901dd
Remove unreachable code in logbook (#103309) 2023-11-04 10:54:22 -05:00
Ville Skyttä 3094991236
Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Marc Mueller 2618bfc073
Use EventType for state changed [core] (#97115) 2023-07-23 18:10:03 -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
Franck Nijhof cbddade4bf
Migrate logbook services to support translations (#96341)
Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
2023-07-12 13:44:15 +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 5114a1400f
Ensure logbook still responds if describe event throws (#91961)
* Ensure logbook still responds if describe event throws

If describe fails, the logbook stream should not collapse

* Ensure logbook still responds if describe event throws

If describe fails, the logbook stream should not collapse
2023-04-24 22:22:53 -04:00
J. Nick Koston b76551cf35
Reduce number of columns selected for logbook (#91718) 2023-04-22 14:25:22 +02:00
J. Nick Koston 95fcdc5684
Speed up sql queries where ORM rows are not needed (#91839)
* Speed up logbook and history queries where ORM rows are not needed

This avoids having sqlalchemy wrap Result in ChunkedIteratorResult
which has additional overhead we do not need for these cases

* more places

* anything that uses _sorted_statistics_to_dict does not need orm rows either
2023-04-21 23:28:07 -04:00
J. Nick Koston 2663901603
Speed up LazyEventPartialState for logbook (#91840)
* Speed up LazyEventPartialState for logbook

We should avoid the getattr call since every row would
have to call the sqlalchemy key not found implemention
if we blindly getattr

* Speed up LazyEventPartialState for logbook

We should avoid the getattr call since every row would
have to call the sqlalchemy key not found implemention
if we blindly getattr
2023-04-21 23:27:23 -04:00
J. Nick Koston 56a6244d90
Remove legacy context lookup implementation from logbook (#91710)
* Remove legacy context lookup implemention from logbook

This object can now be replaced with a simple dict

* Remove legacy context lookup implemention from logbook

This object can now be replaced with a simple dict

* scope

* fix order issue
2023-04-19 21:54:34 -04:00
J. Nick Koston 2530031454
Use cache to lookup event type ids in logbook (#91576)
noticed we can speed this up while looking at
https://github.com/home-assistant/core/issues/91514

Note: this will not fix that issue as there is more going on there
2023-04-17 23:40:03 -04:00
rlippmann f5911bcad6
Add slots to dataclasses in default_config (#91410)
* add dataclass slots to default config items

* remove slots from sun mixing
2023-04-14 14:22:39 -04:00
J. Nick Koston f1fa63281e
Adjust context id variable names in the logbook processor to improve readability (#90617)
Adjust some variable names in the logbook process to improve readablity

There were some places were we used context_id that should have been context_id_bin
2023-04-01 10:24:02 -04:00
J. Nick Koston d21433b6af
Ensure filters are generated inside the lambda locks (#90418) 2023-03-28 20:50:10 +02:00
J. Nick Koston f1ec77b8e0
Small cleanups to logbook statement generator (#90200)
We should only convert the context id to binary if
its going to be used.

Avoid some intermediate vars that are no longer needed
2023-03-23 20:56:58 -04:00
J. Nick Koston f27d73fc34
Remove legacy event lookups from logbook (#89945)
Events recorded with Home Assistant 2022.5.x or older will no
longer display context information in the logbook
2023-03-19 22:05:07 -04:00
J. Nick Koston 7f3e4cb3af
Guard against selecting all invalid entity_ids in history (#89929)
If all the entity_ids that were provided do not exist we would
end up passing an empty list of ids to the SQL query which
would do an unbounded select
2023-03-19 22:03:12 -04:00
J. Nick Koston a244749712
Make StatesMetaManager thread-safe when an entity_id is fully deleted from the database and than re-added (#89732)
* refactor to make StatesMetaManager threadsafe

* refactor to make StatesMetaManager threadsafe

* refactor to make StatesMetaManager threadsafe

* refactor to make StatesMetaManager threadsafe

* reduce

* comments
2023-03-15 08:54:02 -04:00
J. Nick Koston 85ca94e9d4
Mark database sessions that do not write data as read_only (#89600)
* Mark sessions that do not write data as read_only

* Mark sessions that do not write data as read_only
2023-03-12 21:33:28 -04:00
J. Nick Koston c41f91be89
Deduplicate entity_id in the states table (#89557) 2023-03-12 10:01:58 -10:00