Commit Graph

168 Commits (fe010289b4687b4b45dd51ffe43b045a85dca3c1)

Author SHA1 Message Date
Joost Lekkerkerker c1781cd793
Only raise missing integration issue for config entry integrations (#126654) 2024-09-24 18:26:01 +02:00
Joost Lekkerkerker d2dd5ba0e6
Do not raise repair issue about missing integration in safe mode (#123066) 2024-08-02 13:38:56 +02:00
Joost Lekkerkerker 3c14aa12ab
Add repair issue when trying to set up unknown integration (#121089)
* Add repair issue when trying to set up unknown integration

* Add repair issue when trying to set up unknown integration

* Add repair issue when trying to set up unknown integration

* Fix

* Update homeassistant/components/homeassistant/strings.json

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

* Update homeassistant/components/homeassistant/strings.json

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

* Update homeassistant/setup.py

* Fix

---------

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-07-06 15:02:58 +02:00
Marc Mueller ca55986057
Import Generator from collections.abc (1) (#120914) 2024-07-01 11:51:51 +02:00
Marc Mueller fe21e2b8ba
Import Generator from typing_extensions (1) (#118986) 2024-06-06 17:02:13 +02:00
J. Nick Koston e12d23bd48
Speed up async_get_loaded_integrations (#117851)
* Speed up async_get_loaded_integrations

Use a setcomp and difference to find the components to split
to avoid the loop. A setcomp is inlined in python3.12 so its
much faster

* Speed up async_get_loaded_integrations

Use a setcomp and difference to find the components to split
to avoid the loop. A setcomp is inlined in python3.12 so its
much faster

* simplify

* fix compat

* bootstrap

* fix tests
2024-05-21 09:08:49 -04:00
J. Nick Koston 149120b749
Add setup time detail to diagnostics (#117766) 2024-05-20 09:52:28 +02:00
J. Nick Koston 13414a0a32
Pass loop to create_eager_task in loops from more coros (#117390) 2024-05-14 09:48:25 +09:00
J. Nick Koston b061e7d1aa
Small speed up to setting up integrations and config entries (#117278)
* Small speed up to setting up integration and config entries

When profiling tests, I noticed many calls to get_running_loop. In the places
where we are already in a coro, pass the existing loop so it does not have to
be looked up. I did not do this for places were we are not in a coro since there
is risk that an integration could be doing a non-thread-safe call and its better
that the code raises when trying to fetch the running loop vs the performance
improvement for these cases.

* fix merge

* missed some
2024-05-11 22:39:20 -04:00
Marc Mueller c50a340cbc
Use HassKey for setup and bootstrap (#116998) 2024-05-07 11:18:20 -05:00
Sid 2cc916db6d
Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
Marc Mueller 3d700e2b71
Add HassDict implementation (#103844) 2024-05-07 10:53:13 +02:00
J. Nick Koston 6cf1c5c1f2
Hold a lock to prevent concurrent setup of config entries (#116482) 2024-04-30 18:47:12 -05:00
J. Nick Koston 164403de20
Add thread safety checks to async_create_task (#116339)
* Add thread safety checks to async_create_task

Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here

* Add thread safety checks to async_create_task

Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here

* missed one

* Update homeassistant/core.py

* fix mocks

* one more internal

* more places where internal can be used

* more places where internal can be used

* more places where internal can be used

* internal one more place since this is high volume and was already eager_start
2024-04-28 18:29:00 -04:00
J. Nick Koston ab2ea6100c
Speed up singleton decorator so it can be used more places (#116292) 2024-04-28 12:11:08 -05:00
J. Nick Koston a22c221722
Rename bus._async_fire to bus.async_fire_internal (#116027) 2024-04-23 22:28:31 +02:00
J. Nick Koston 11ff00f637
Small speed up to async_prepare_setup_platform (#115662) 2024-04-15 17:30:05 -05:00
J. Nick Koston 41f5325ce3
Refactor _async_setup_component to remove need for C901 (#115553) 2024-04-13 19:46:37 -05:00
J. Nick Koston dad03e7283
Remove sleep in async_setup_component (#115515)
Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
2024-04-13 19:34:28 -05:00
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 e0f5559c8f
Improve generic event typing [EventComponentLoaded] (#114739) 2024-04-06 14:18:03 +02:00
J. Nick Koston 17da077c74
Avoid trying to load platform that are known to not exist in async_prepare_setup_platform (#114659) 2024-04-02 11:22:40 -10:00
Sid 6587ee20db
Enable Ruff TRY300 (#114437)
* Enable Ruff TRY300

* Update validation.py

* Address review comments
2024-03-30 10:37:59 +01:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
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
J. Nick Koston e8cb6a8e29
Optimize loading of translations (#114089) 2024-03-23 22:22:09 -10:00
J. Nick Koston 4f18f0d902
Fix setup timings when config entry platform loads are not awaited (#113959)
* Move setup time logging into the context manager

We were fetching the time twice but since the context
manager already has the timing, move it there

* remove log setup assertions from integration test

* tweak logging to give us better data for tracking issues

* redundant

* adjust

* preen

* fixes

* adjust

* make api change internal so nobody uses it

* coverage

* fix test

* fix more tests

* coverage

* more tests assuming internal calls

* fix more

* adjust

* adjust

* fix axis tests

* fix broadlink -- it does not call async_forward_entry_setup

* missed some

* remove useless patch

* rename, detect it both ways

* clear

* debug

* try to fix

* handle phase finishing out while paused

* where its set does not need to know its late as that is an implemenation detail of setup

* where its set does not need to know its late as that is an implemenation detail of setup

* tweak

* simplify

* reduce complexity

* revert order change as it makes review harder

* revert naming changes as it makes review harder

* improve comment

* improve debug

* late dispatch test

* test the other way as well

* Update setup.py

* Update setup.py

* Update setup.py

* simplify

* reduce
2024-03-23 15:26:38 -04:00
Erik Montnemery d31124d5d4
Avoid creating unneeded Context and Event objects when firing events (#113798)
* 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 879e5bc961
Only wait for import flows in setup of there is a config flow (#113780) 2024-03-19 10:38:27 -10:00
J. Nick Koston c615b52840
Refactor integration startup time to show wall clock time (#113707)
* Refactor setup time tracking to exclude time waiting on other operations

We now exclude the import time and th time waiting on
base platforms to setup from the setup times

* tweak

* tweak

* tweak

* tweak

* adjust

* fixes

* fixes

* preen

* preen

* tweak

* tweak

* adjust

* tweak

* reduce

* do not count integrtion platforms against their parent integration

* handle legacy tts platforms

* stt as well

* one more wait

* use the same pattern in all the legacy

* fix tts and stt legacy

* fix

* fix

* reduce

* preen

* entity comp does not wait for platforms

* scene blocks as well

* fix test

* test fixes

* coverage

* coverage

* coverage

* fix test

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/test_setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/setup.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* strip

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* strip WAIT_PLATFORM_INTEGRATION

* remove complexity

* Apply suggestions from code review

* no longer works that way

* fixes

* fixes

* fixes

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-18 21:45:34 -04:00
J. Nick Koston 5e94858821
Migrate _async_when_setup to use eager_start (#112872)
This one does not make much difference, but its a lot
easier to do it now instead of in the future
2024-03-11 15:02:35 -04:00
Marc Mueller de886d8c49
Update EventBus listen type signatures (#112760) 2024-03-08 21:57:23 +01:00
Marc Mueller cef20506dc
Replace EventType with Event [missing] (#112753) 2024-03-08 21:56:42 +01:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
J. Nick Koston d6cbadba3e
Ensure setup loads top level component before platforms (#112057) 2024-03-03 11:42:16 -10:00
J. Nick Koston 9af12a0639
Avoid calling async_get_component twice for each component being setup (#112096)
We already have the component so we can pass it to
async_process_component_config to avoid having to
look it up again
2024-03-03 12:48:07 -05:00
J. Nick Koston 6abb8ae273
Migrate setup to use eager tasks (#111619) 2024-02-27 12:43:32 -10:00
J. Nick Koston 4ea1c5cc3c
Add support for importing integrations in the executor (#111336)
* Add support for pre-imports at setup time

alternative solution to #111331

* refactor

* refactor

* refactor

* mark >1.0s integrations

* no point in executor if already loaded

* no point in executor if already loaded

* cleanup

* cleanup

* two more

* one more

* analytics loads a lot more integrations

* cloud

* debug

* psutil, hardwre

* try zha

* Update homeassistant/setup.py

* await

* comments

* coverage

* coverage

* coverage

* move logic to loader

* move logic to loader

* preserve comments
2024-02-26 14:49:43 -05:00
J. Nick Koston dd80157dc7
Load translations at setup time if they were not loaded at bootstrap (#110921) 2024-02-24 11:31:25 -10:00
Marc Mueller 5f8ef37f2d
Update pylint to 3.0.4 (#111229)
* Update pylint to 3.0.4

* Use yield from

* Remove unnecessary pylint disable comments
2024-02-23 23:46:00 +01:00
J. Nick Koston 2ef71289b9
Avoid creating tasks for dependencies already being setup (#111034)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-02-22 12:34:46 -10:00
J. Nick Koston 4bc28489c5
Improve performance of waiting for after dependencies and device config entries (#110902)
To wait for after dependencies we created a task to wait an asyncio.Event object,
instead of using an Event we can use an asyncio.Future instead and avoid the need
for a task wrapper
2024-02-19 10:28:50 +01:00
Marc Mueller 85864e77ac
Partially revert setup typing update (#110901) 2024-02-19 00:36:47 +01:00
J. Nick Koston 314123e0ab
Avoid creating two tasks to setup components at startup (#110828) 2024-02-18 14:17:41 -06:00
J. Nick Koston def6c5c21c
Refactor integration startup time tracking to reduce overhead (#110136)
* Refactor integration startup time tracking to reduce overhead

- Use monotonic time for watching integration startup time as it avoids incorrect values if time moves backwards because of ntp during startup and reduces many time conversions since we want durations in seconds and not local time

- Use loop scheduling instead of a task

- Moves all the dispatcher logic into the new _WatchPendingSetups

* websocket as well

* tweaks

* simplify logic

* preserve logic

* preserve logic

* lint

* adjust
2024-02-17 21:47:55 -05:00
J. Nick Koston 0d6f4058ca
Add typing for EVENT_COMPONENT_LOADED (#110812) 2024-02-17 23:03:52 +01:00
J. Nick Koston b8143a7944
Improve performance of _async_when_setup (#110791)
* Improve performance of _async_when_setup

Use an event filter to avoid creating a task until the
filter matches

* Improve performance of _async_when_setup

Use an event filter to avoid creating a task until the
filter matches
2024-02-17 17:46:06 +01:00
J. Nick Koston 0bf95df4d6
Avoid creating tasks to setup ignored and disabled config entries (#110756)
* Avoid creating tasks to setup ignored and disabled config entries

* lint
2024-02-17 10:34:03 +01:00
Marc Mueller cd0ee98dba
Use builtin TimeoutError [core + helpers] (#109684) 2024-02-05 12:09:54 +01:00
Erik Montnemery 5e79cd8715
Remove file/line annotations after config has been validated (#107139) 2024-01-14 11:07:39 +01:00
Erik Montnemery 25bea91683
Use modern platform path when reporting platform config errors (#104238)
* Use modern platform path when reporting platform config errors

* Update tests

* Address review comment

* Explicitly pass platform domain to log helpers

* Revert overly complicated changes

* Try a simpler solution
2023-12-05 15:06:13 +01:00