Commit Graph

57 Commits (7433d2eca998a20a1d79b84ece81fdda76a4da48)

Author SHA1 Message Date
J. Nick Koston 91fa8b50cc
Turn on thread safety checks in async_dispatcher_send (#116867)
* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* adjust
2024-05-05 16:29:43 -04:00
J. Nick Koston 56d0ad27f0
Adjust async_load_platform comment to remove dead lock reference (#114771)
* Adjust async_load_platform comment

Its likely the deadlock here has been fixed for a long time, however
we should still do these in a task because it has to wait for base
components if they are not loaded yet.

* Adjust async_load_platform comment

Its likely the deadlock here has been fixed for a long time, however
we should still do these in a task because it has to wait for base
components if they are not loaded yet.
2024-04-03 22:53:31 -04:00
Marc Mueller 1d2c2d2055
Move SignalTypes to util (#114236) 2024-03-27 08:41:44 +01:00
Marc Mueller eb81a4204e
Allow string formatting for dispatcher SignalType (#114174) 2024-03-26 10:38:29 +01:00
J. Nick Koston 620433a79d
Run coroutines as eager tasks in async_run_hass_job (#111683)
* Run coroutines as eager tasks in async_run_hass_job

Note that this does not change async_add_hass_job

Do not merge this. For test run only

* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* limit first scope to triggers

* one more

* Start tasks eagerly in for async_at_start(ed)

A few of these can avoid being scheduled on the loop
during startup

* fix cloud

* Revert "fix cloud"

This reverts commit 5eb3ce695d.

* fix test to do what start does

* flip flag

* flip flag

* Fix here_travel_time creating many refresh requests at startup

- Each entity would try to refresh the coordinator which
  created many tasks. Move the refresh to a single
  async_at_started

- The tests fired the EVENT_HOMEASSISTANT_START event
  but the code used async_at_started which only worked
  because the tests did not set CoreState to not_running

* fix azure

* remove kw

* remove kw

* rip

* cover

* more rips

* more rips

* more rips
2024-03-11 20:05:08 -04:00
J. Nick Koston 9ba142f4dd
Use eager_start for discovery listeners (#112803)
Many platforms can be loaded without having to suspend or
be scheduled on the event loop
2024-03-09 11:07:15 -05:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
J. Nick Koston 5eb0c35a97
Add names to common helper tasks (#90803) 2023-04-05 08:41:15 +02:00
J. Nick Koston 2e0ecf9bd9
Avoid more task creation in the discovery helper (#90552)
* Avoid more task creation in the discovery helper

There is no longer a reason to awaiti the jobs being dispatched
since nothing was using the result and there is no risk of
job being garbage collected prematurely anymore since
the task revamp

* Update homeassistant/helpers/discovery.py
2023-03-31 09:10:55 +02:00
J. Nick Koston 11681f3f31
Pass a helpful name when creating common asyncio tasks in core (#89171) 2023-03-05 12:46:02 +01:00
Marc Mueller dc47121f2c
Better type hass_job method calls (#76053) 2022-08-09 16:12:33 -04:00
Erik Montnemery f4fb29200c
Allow empty config in discovery.async_load_platform (#69619) 2022-04-07 23:24:47 +02:00
Jan Bouwhuis cfc8b5fee7
Fix notify discovery setup (#68451)
* Fix notify discovery setup

* add test

* unsubscribe at reset

* Add guard

* move dispatcher to reload module

* only unsubscribe if platform was setup

* initialize dispatcher once and tests

* test get_service too

* add tests

* fix test

* use get_service for test invalid platform

* Test built-in reload method

* set to None after clearing dispatcher - tests

* Pathing services file

* Update tests/components/notify/test_init.py

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

* dispatcher is not set twice if integration loaded

* empty discovery payload

* Removed not needed services.yaml mock

* Update tests/components/notify/test_init.py

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

* flake8

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-03-28 08:53:30 +02:00
epenet 0a7b1dec7d
Adjust type hint in core add_job (#66503)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-14 11:13:10 +01:00
epenet 128256a3ee
Fix invalid type hint in discovery async_listen (#63987)
* Fix invalid type hint in discovery async_listen

* Add setup type hints to sabnzbd

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-13 02:43:43 +01:00
Marc Mueller 240c9979c7
Move `disallow-any-generics` to mypy.ini (#63917) 2022-01-11 13:33:25 -08:00
epenet 51292cc135
Fix incorrect type hint in discovery helper (#63789)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-10 11:14:31 +01:00
epenet 665eeb4b27
Explicitely allow Platform enum in discovery helper (#63571)
* Adjust Platform type hint in discovery helper

* Adjust amcrest

* Adjust comfoconnect

* Adjust ecovacs

* Adjust egardia

* Rename arguments

* Convert Platform enum to string explicitely

* Revert "Adjust egardia"

This reverts commit ff7b0d6100.

* Revert "Adjust ecovacs"

This reverts commit 2749045e13.

* Revert "Adjust comfoconnect"

This reverts commit bfff08f7fc.

* Undo argument name change and conversion to string

* Remove comment

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-09 06:06:56 +01:00
Marc Mueller 238b488642
Use assignment expressions 03 (#57710) 2021-10-17 20:08:11 +02:00
Marc Mueller 77ee72cbb9
Import Callable from collections.abc (1) (#56775) 2021-09-29 16:32:11 +02:00
Marc Mueller 6fb2e63e49
Update typing 02 (#48014) 2021-03-17 18:34:19 +01:00
Paulus Schoutsen 557ec374f1
Convert discovery helper to use dispatcher (#47008) 2021-02-24 13:37:31 -08:00
Ville Skyttä 82607977ef
Various type hint improvements (#46144) 2021-02-08 11:59:46 +01:00
Paulus Schoutsen 5b6d9abe2a
Await callbacks to keep cleaner stacktraces (#43693) 2020-11-27 17:48:43 +01:00
J. Nick Koston 852d1b2e67
Update discovery to use HassJob (#41511)
Predetermine the listener types for discovery
2020-10-09 09:35:28 +02:00
Paulus Schoutsen 8f3c84b349
Mark config dependency of frontend (#36587) 2020-06-09 23:27:47 -07:00
Ville Skyttä 267d98b5eb
Type hint improvements (#33082) 2020-04-17 11:33:58 -07:00
Ville Skyttä 05abf37046
Type hint improvements (#32905)
* Complete helpers.entity_component type hints

* Add discovery info type
2020-03-18 19:27:25 +02:00
Ville Skyttä fa4fa30461 Various string cleanups (#30435)
* Remove some unnecessary string concatenations

* Replace some simple str.formats with f-strings

* Replace some string concatenations with f-strings
2020-01-03 14:47:06 +01:00
Ville Skyttä 6604680793
Helpers type hint improvements (#30106) 2019-12-21 09:23:48 +02:00
Bas Nijholt 67c56c860d Sort imports according to PEP8 for 'homeassistant' folder (#29789)
Components are already done
2019-12-09 16:42:10 +01:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Ville Skyttä d64f1e767c Type check all helpers (#25373)
* Type check all helpers, add inline exclusions for work in progress

* Remove unused Script._template_cache

* Add some missing type hints

* Remove unneeded type: ignore

* Type hint fixes

* Mypy assistance tweaks

* Don't look for None in deprecated config "at most once" check

* Avoid None name slugify attempt when generating entity id

* Avoid None state store attempt on entity remove
2019-07-21 09:59:02 -07:00
Paulus Schoutsen 6b0180f753
Fix demo (#23087)
* Fix demo

* Fix types

* Fix all the things

* Fix type

* Fix test

* Lint
2019-04-14 16:59:06 -07:00
Matthias Urlichs b506aafbb4 docstring fix (#18257) 2018-11-06 12:41:15 +01:00
Paulus Schoutsen 6ae345b01c
Pass hass_config to load_platform (#17952)
* Pass hass_config to load_platform

* Fix tests

* Lint
2018-10-29 19:21:21 +01:00
Ville Skyttä dbd0763f83 Grammar and spelling fixes (#16065) 2018-08-19 22:29:08 +02:00
Paulus Schoutsen ea2ff6aae3
Use async_create_task (#15633)
* Use async_create_task

* Fix test
2018-07-23 14:05:38 +02:00
Paulus Schoutsen 5a9013cda5
Refactor Hue: phue -> aiohue (#13043)
* phue -> aiohue

* Clean up

* Fix config

* Address comments

* Typo

* Fix rebase error

* Mark light as unavailable when bridge is disconnected

* Tests

* Make Throttle work with double delay and async

* Rework update logic

* Don't resolve host to IP

* Clarify comment

* No longer do unnecessary updates

* Add more doc

* Another comment update

* Wrap up tests

* Lint

* Fix tests

* PyLint does not like mix 'n match async and coroutine

* Lint

* Update aiohue to 1.2

* Lint

* Fix await MagicMock
2018-03-16 20:27:05 -07:00
Matthias Urlichs f5cc40024d Rename homeassistant.util.async to .async_ (#13088)
"async" is (going to be) a reserved word.
2018-03-11 10:01:12 -07:00
Eitan Mosenkis 95cd2035b6 Fix incorrect comment. (#11111) 2017-12-13 00:04:42 +01:00
Paulus Schoutsen ca54bbfcc9 RFC: Use bind_hass for helpers (#9745)
* Add Helpers bind_hass functionality

* Update other helpers
2017-10-08 08:17:54 -07:00
Fabian Affolter 0863d50210 Fix typos (#7957)
Add an optional extended description…
2017-06-08 15:53:12 +02:00
Fabian Affolter a4f1f6e724 Update docstrings (#7374)
* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstring

* Update docstrings

* Update docstrings

* Fix lint issues

* Update docstrings

* Revert changes in dict
2017-05-02 09:18:47 -07:00
Paulus Schoutsen 2650c73a89 Split bootstrap into bs + setup (#6416)
* Split bootstrap into bs + setup

* Lint
2017-03-05 10:41:54 +01:00
Pascal Vizeli 41f558b181 Bootstrap / Component setup async (#6264)
* Bootstrap / Entiy setup async

* Cleanup add_job stuff / return task/future object

* Address paulus comments / part 1

* fix install pip

* Cleanup bootstrap / move config stuff to config.py

* Make demo async

* Further bootstrap improvement

* Address Martin's comments

* Fix initial tests

* Fix final tests

* Fix bug with prepare loader

* Remove no longer needed things

* Log error when invalid config

* More cleanup

* Cleanups platform events & fix lint

* Use a non blocking add_entities callback for platform

* Fix Autoamtion is setup befor entity is ready

* Better automation fix

* Address paulus comments

* Typo

* fix lint

* rename functions

* fix tests

* fix test

* change exceptions

* fix spell
2017-02-28 20:33:19 -08:00
Paulus Schoutsen f29ee24b72 Do not allow config dependency (#6036)
* Do not allow config dependency

* Prevent config in discovery

* Migrate to blacklist
2017-02-18 11:31:37 -08:00
Paulus Schoutsen c81735cc84 Fix platform discovery when platform discovered during discovery of a (#4529)
component
2016-11-22 08:21:08 -08:00
Pascal Vizeli 835577b2bc Bugfix discovery use wrong time async (#4515)
* Bugfix discovery use wrong time async

* fix lint
2016-11-21 19:33:08 -08:00
Paulus Schoutsen 455e1df7cb Fix typo 2016-11-19 16:05:33 -08:00