Commit Graph

207 Commits (d09a274548ef9abb73617fc92781a18becc75766)

Author SHA1 Message Date
Erik Montnemery 75c7ae7c69
Support in service descriptions for input sections (#116100) 2024-06-25 20:00:48 +02:00
Marc Mueller 62fd692d27
Improve async_register_admin_service schema typing (#120405) 2024-06-25 12:48:00 +02:00
Erik Montnemery 8620bef5b0
Support shared keys starting with period in services.yaml (#118789) 2024-06-11 16:31:19 +02:00
Paulus Schoutsen 52ad90a68d
Include script description in LLM exposed entities (#118749)
* Include script description in LLM exposed entities

* Fix race in test

* Fix type

* Expose script

* Remove fields
2024-06-04 11:18:07 -04:00
Marc Mueller dd22ee3dac
Improve annotation styling (#118032) 2024-05-24 15:05:53 +02:00
J. Nick Koston 905692901c
Simplify service description cache logic (#117846) 2024-05-21 09:02:32 -04:00
Marc Mueller 8f0fb4db3e
Use PEP 695 for class annotations (4) (#117778) 2024-05-20 10:44:52 +02:00
Marc Mueller 900b6211ef
Use PEP 695 for function annotations (2) (#117659) 2024-05-18 11:44:39 +02:00
Marc Mueller 4edee94a81
Update mypy-dev to 1.11.0a2 (#117630) 2024-05-17 13:32:20 +02:00
Marc Mueller ab07bc5298
Improve ReloadServiceHelper typing (#117552) 2024-05-16 12:47:43 +02:00
Marc Mueller 8f614fb06d
Use HassKey for helpers (2) (#117013) 2024-05-07 11:24:13 -05:00
Erik Montnemery 7cd0fe3c5f
Don't reload other automations when saving an automation (#80254)
* Only reload modified automation

* Correct check for existing automation

* Add tests

* Remove the new service, improve ReloadServiceHelper

* Revert unneeded changes

* Update tests

* Address review comments

* Improve test coverage

* Address review comments

* Tweak reloader code + add a targetted test

* Apply suggestions from code review

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

* Explain the tests + add more variations

* Fix copy-paste mistake in test

* Rephrase explanation of expected test outcome

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-16 15:58:57 +02:00
Sid 3799d20d43
Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
Jan Bouwhuis 10076e6523
Add notify entity component (#110950)
* Add notify entity component

* Device classes, restore state, icons

* Add icons file

* Add tests for kitchen_sink

* Remove notify from no_entity_platforms in hassfest icons, translation link

* ruff

* Remove `data` feature

* Only message support

* Complete initial device classes

* mypy pylint

* Remove device_class implementation

* format

* Follow up comments

* Remove _attr_supported_features

* Use setup_test_component_platform

* User helper at other places

* last comment

* Add entry unload test and non async test

* Avoid default mutable object in constructor
2024-04-11 12:04:08 +02:00
J. Nick Koston aedfd6c983
Add index for floor/label to the area registry (#114777) 2024-04-03 21:04:26 -10:00
J. Nick Koston 3f76d1f056
Add index for area/config_entry/label to the device registry (#114776)
* Add index for area/config_entry/label to the device registry

* use it for services

* naming

* naming

* tweak
2024-04-03 22:52:17 -04:00
J. Nick Koston e86fec310b
Improve performance of extracting entities by label (#114720) 2024-04-03 10:24:44 -10: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
Franck Nijhof 167e66d45c
Add labels to service target (#113753) 2024-03-18 22:32:23 +01:00
Sid 6ee273a548
Clean up unneeded ruff noqa directives (#113616) 2024-03-16 09:48:37 -10:00
Franck Nijhof 2aadd643ed
Add floors to service target (#110850) 2024-03-14 19:02:23 +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
Paulus Schoutsen 145657dc21
Only load services.yaml for integrations that have it (#112732)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-11 19:05:32 +01:00
J. Nick Koston b7d9f26cee
Cache the job type for entity service calls (#112793) 2024-03-08 22:49:08 -10:00
J. Nick Koston a50883d975
Run service call tasks eagerly (#112791) 2024-03-08 20:37:21 -10:00
Marc Mueller 19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
Marc Mueller daf8d1939b
Fix generic HassJob typing (#111973) 2024-03-01 20:51:45 +01:00
J. Nick Koston 913ee90e1a
Use eager tasks when updating entity state after service calls (#111702)
In a multi-entity update case the state update may not need
to suspend and can get executed without scheduling a task
on the event loop
2024-02-28 12:46:32 +01:00
J. Nick Koston 9689cb448d
Avoid linear search of entity registry in async_extract_referenced_entity_ids (#109667)
* Index area_ids in the entity registry

I missed that these are used in _resolve_area in search.

Eventually we can make async_extract_referenced_entity_ids
a bit faster with this as well

* Avoid linear search of entity registry in async_extract_referenced_entity_ids

needs https://github.com/home-assistant/core/pull/109660
2024-02-09 09:42:30 -05:00
J. Nick Koston 40166ed51e
Avoid linear search of device registry when no areas are referenced in service calls (#109669) 2024-02-05 12:26:08 +01:00
J. Nick Koston 2f724b042b
Avoid looking up services to check if they support responses (#109588)
We already have the Service object as its the value in the
services_map so there is not need to look it up again
2024-02-04 15:15:51 +01:00
J. Nick Koston ed726db974
Fix race in loading service descriptions (#109316) 2024-02-01 12:34:23 -06:00
J. Nick Koston 7c86ab14c3
Refactor service enumeration methods to better match existing use cases (#108671) 2024-01-22 14:21:17 -10:00
J. Nick Koston e9a7870080
Small cleanups to async_get_all_descriptions (#108633) 2024-01-21 18:09:33 -10:00
J. Nick Koston 573de95f21
Speed up run time of admin services by using HassJob (#108623) 2024-01-21 22:41:41 -05:00
Marc Mueller 78752264b3
Fully type homeassistant integration (#107380) 2024-01-08 10:07:30 +01:00
J. Nick Koston d260ed938a
Reduce overhead to call entity services (#106908) 2024-01-08 09:30:52 +01:00
J. Nick Koston 0695bf8988
Move group helpers into their own module (#106924)
This gets rid of the legacy need to use bind_hass, and
the expand function no longer looses typing.
2024-01-04 17:34:56 +01:00
J. Nick Koston 09b65f14b9
Index entities by domain for entity services (#106759) 2024-01-02 15:28:58 +01:00
Bram Kragten 7ba1736637
Filter by supported features for todo services (#106241) 2023-12-22 21:22:16 +01:00
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
Erik Montnemery 5b55c7da5f
Remove logic converting empty or falsy YAML to empty dict (#103912)
* Correct logic converting empty YAML to empty dict

* Modify according to github comments

* Add load_yaml_dict helper

* Update check_config script

* Update tests
2023-12-05 18:08:11 +01:00
Ruslan Sayfutdinov adcd4e59cf
More useful message on services.yaml parse error (#103847) 2023-11-12 16:18:12 +00:00
Marc Mueller c35f56ea77
Handle BaseException from asyncio gather (#103814) 2023-11-11 22:26:37 +01:00
Kevin Stillhammer 06c9719cd6
Support multiple responses for service calls (#96370)
* add supports_response to platform entity services

* support multiple entities in entity_service_call

* support legacy response format for service calls

* revert changes to script/shell_command

* add back test for multiple responses for legacy service

* remove SupportsResponse.ONLY_LEGACY

* Apply suggestion

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* test for entity_id remove None

* revert Apply suggestion

* return EntityServiceResponse from _handle_entity_call

* Use asyncio.gather

* EntityServiceResponse not Optional

* styling

---------

Co-authored-by: Allen Porter <allen.porter@gmail.com>
2023-11-02 18:37:35 -07:00
Erik Montnemery 09ad1a9a36
Remove unnecessary block use of pylint disable in components p-z (#100192) 2023-09-12 20:47:48 +02:00
J. Nick Koston 3d403c9b60
Refactor entity service calls to reduce complexity (#99783)
* Refactor entity service calls to reduce complexity

gets rid of the noqa C901

* Refactor entity service calls to reduce complexity

gets rid of the noqa C901

* short
2023-09-08 13:04:53 -04:00
Ville Skyttä 3094991236
Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Franck Nijhof b655b9d530
Allow for translating service examples (#97141) 2023-07-24 15:57:02 +02:00
J. Nick Koston 3a06659120
Speed up single entity/response service calls (#96729)
* Significantly speed up single entity/response service calls

Since the majority of service calls are single entity, we can
avoid creating tasks in this case. Since the multi-entity
service calls always check the result and raise, we can switch
the asyncio.wait to asyncio.gather

* Significantly speed up single entity/response service calls

Since the majority of service calls are single entity, we can
avoid creating tasks in this case. Since the multi-entity
service calls always check the result and raise, we can switch
the asyncio.wait to asyncio.gather

* revert

* cannot be inside pytest.raises

* one more

* Update homeassistant/helpers/service.py
2023-07-17 09:33:13 +02:00