Commit graph

177 commits

Author SHA1 Message Date
Franck Nijhof
284fc94d31
Add initial label registry foundation
Add label support to device registry

Add label support to entity registry

Add support for calling services by labels

Rebase fixes, test fixes, linter fixes, catch up

Ran black

Update test snapshosts

Update snapshots for renault

Register API

Fix entity registry tests

Set up registry in bootstrap

Add labels to partial dict

Add support to Syrupy for test snapshotting

Adjust more tests

Adjust version in comment

Update snapshots

Add template methods
2024-02-01 23:35:13 +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
J. Nick Koston
08af42b00e
Fix mixed case service schema registration (#96448) 2023-07-12 14:39:51 -10:00
Franck Nijhof
594d240a96
Migrate & fix logger services to support translations (#96393)
* Migrate logger services to support translations

* Fix tests and schema validation

* Apply suggestions from code review

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
2023-07-12 10:37:18 -04:00
Franck Nijhof
f25d5a157a
Fix service schema to allow for services without any fields/properties (#96346) 2023-07-11 19:33:07 +02:00
Franck Nijhof
f054de0ad5
Add support for service translations (#95984) 2023-07-11 15:52:12 +02:00
J. Nick Koston
b7b8afffd0
Handle integrations with empty services or failing to load during service description enumeration (#95911)
* wip

* tweaks

* tweaks

* add coverage

* complain loudly as we never execpt this to happen

* ensure not None

* comment it
2023-07-06 11:19:06 -04:00
Bram Kragten
342d07cb92
Set correct response value in service description when async_set_service_schema is used (#95985)
* Mark scripts as response optional, make it always return a response if return_response is set

* Update test_init.py

* Revert "Update test_init.py"

This reverts commit 8e113e54db.

* Split + add test
2023-07-06 10:24:34 -04:00
Paulus Schoutsen
e4f617e92e
Update log message when referenced entity not found (#95577)
* Update log message when referenced entity not found

* Update homeassistant/helpers/service.py

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

* Update test

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-07-02 00:04:03 +02:00
Paulus Schoutsen
d95c241a1a
Add service response values to service descriptions (#95262) 2023-06-26 12:57:43 -04:00
Allen Porter
b9b5fe6be8
Add service response data for listing calendar events (#94759)
* Add service response data for listing calendar events

Add the capability of response data for for the entity component.

* Rename input arguments and add service description

* Improve list events to be more user friendly

Allow the end date to be determined based on a relative time duration. Make the start time optional and set to "now". Add additional test coverage. Update demo calendar to actually perform date range checks.

* Wrap docstrings properly.

* Increase test coverage

* Update to use new API calls

* Readability improvements

* Wrap docstrings

* Require at least one of end or duration

* Check for multiple entity matches earlier in the request

* Update documentation strings
2023-06-23 23:34:34 -04:00
J. Nick Koston
68cf796be8
Speed up entity service calls (#94731)
* Speed up entity service calls

- Avoid permissions check if the caller is an admin
- Use set intersection instead of linear search of entity platforms to find entities

* tweak

* fix light test to not use an admin user
2023-06-16 21:07:57 -04:00
J. Nick Koston
b993fe1c9d
Cache generation of the service descriptions (#93131) 2023-05-16 21:42:37 -05:00
rlippmann
3a72054f93
Make dataclasses in HA core slotted (#91208) 2023-04-11 07:58:28 -10:00
Erik Montnemery
9384ec18f8
Add filters to climate and light service descriptions (#86162)
* Add filters to climate and light service descriptions

* Allow specifying enums directly

* Update service descriptions

* Adjust test

* Cache entity features

* Lint

* Improve error handling, add list of known base components

* Don't allow specifying an entity feature as int
2023-03-16 15:59:51 +01:00
J. Nick Koston
bea81d3f63
Fix lock services not removing entity fields (#88805) 2023-02-26 18:59:28 -05:00
Franck Nijhof
5e81d28116
Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
Marc Mueller
4f87c1f30f
Update pre-commit-config [Py310] (#86415) 2023-01-23 09:59:44 +01:00
Franck Nijhof
06a35fb7db
Code styling tweaks to core helpers (#85441) 2023-01-08 13:44:09 -10:00
Franck Nijhof
d4f69a3652
String formatting and max line length - Part 7 (#84532)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 11:18:56 +01:00
Marc Mueller
63d519c1a8
Spelling updates (#82867) 2022-11-28 16:51:43 +01:00
Aarni Koskela
8038485ca4
Use partition instead of split where possible in core (#81806) 2022-11-15 21:45:48 +01:00
Erik Montnemery
18033532ca
Fix search throwing on templated services (#79637) 2022-10-05 10:59:18 +03:00
epenet
8300f8234c
Make async_extract_entities generic (#78490) 2022-09-16 00:20:47 +02:00
J. Nick Koston
61cc9f5288
Consolidate executor jobs when loading integration manifests (#75176) 2022-07-14 13:06:08 -07:00
Paulus Schoutsen
d59258bd25
Revert "Add service entity context (#71558)" (#72610) 2022-05-27 10:30:40 -07:00
Franck Nijhof
69cc6ab5f1
Clean up accessing entity_registry.async_get_registry helper via hass (#72005) 2022-05-17 16:40:45 +02:00
Paulus Schoutsen
64636a4310
Add service entity context (#71558)
Co-authored-by: Shay Levy <levyshay1@gmail.com>
2022-05-09 14:45:53 -07:00
Joakim Plate
2dbe910e31
Adjust warning for missing entites (#71343) 2022-05-09 12:37:24 +02:00
Erik Montnemery
eb068bc850
Fix targeting all or none entities in service calls (#68513)
* Fix targeting all or none entities in service calls

* Add test
2022-03-22 19:45:27 +02:00
Paulus Schoutsen
8bbbd1947d
Raise if referenced entity does not support service (#68394) 2022-03-20 16:01:58 -07:00
Erik Montnemery
34eb4aa2d0
Exclude hidden entities from targets (#68149) 2022-03-15 08:42:22 -07:00