Commit graph

129 commits

Author SHA1 Message Date
Joost Lekkerkerker
3810c3cbaf
Improve trigger schema validation to ask for trigger instead of platform (#126750)
* Add check for missing trigger

* Fix

* Fix

* Escape
2024-09-25 16:44:14 +02:00
Joost Lekkerkerker
a1906b434f
Change trigger platform key to trigger (#124357)
* fix

* Fix

* Fix

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix

* Fix

* Fix

* Fix

* Add more tests

* Fix

* Fix tests

* Add tests

* Let's see what the CI does

* It fails on the code that tested the thing ofc

* It fails on the code that tested the thing ofc

* Revert test thingy

* Now the test works again, lovely

* Another one

* Fix websocket thingy

* Only copy when needed

* Improve comment

* Remove test

* Fix docstring

* I think this now also work since this transforms trigger to platform

* Add comment

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Check for mapping

* Add test

* Update homeassistant/helpers/config_validation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update test to also test for trigger keys

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-09-25 14:19:58 +02:00
epenet
2c210e4b58
Use root import for websocket_api (#125834) 2024-09-12 19:31:57 +02:00
Marc Mueller
49df0c4366
Improve schema typing (2) (#120475) 2024-06-26 02:25:30 +02:00
epenet
960d1289ef
Avoid references to websocket_api.const in core and other components (#119285) 2024-06-10 13:49:44 +02:00
Marc Mueller
87bb7ced79
Use PEP 695 for simple type aliases (#117633) 2024-05-17 14:42:21 +02: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
Marc Mueller
aa16a9d707
Add empty line after module docstring (3) (#112750) 2024-03-08 20:38:34 +01:00
Marc Mueller
0e3945ca6c
Add empty line after module docstring [d-f] (#112698) 2024-03-08 14:15:26 +01:00
J. Nick Koston
613bf1c226
Migrate device_automation to use async_get_platform (#112162)
This ensures that if device_automation loads an integration's
platform it will get loaded in the executor if enabled
2024-03-04 06:11:34 -05:00
J. Nick Koston
9fef1938b4
Make get_entries_for_device_id skip disabled devices by default (#109645) 2024-02-04 23:11:56 +01:00
J. Nick Koston
f37db94f23
Avoid linear search of entity registry in async_get_device_automations (#109633) 2024-02-04 14:22:12 -06: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
087df10d27
Improve validation of device automations (#102766)
* Improve validation of device automations

* Improve comments

* Address review comment
2023-10-26 09:46:16 +02:00
Erik Montnemery
57352578ff
Use entity registry id in zwave_js device actions (#96407) 2023-07-18 09:36:40 +02:00
Erik Montnemery
916e7dd359
Fix a couple of typos (#96298) 2023-07-11 17:28:54 +02:00
Erik Montnemery
179e1da164
Use entity registry id in text device actions (#95398) 2023-06-27 20:24:40 +02:00
Erik Montnemery
c2f7e5840b
Use entity registry id in climate device actions (#95268)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-06-27 09:28:54 +02:00
Erik Montnemery
51aa2ba835
Use entity registry id in water_heater device actions (#95276) 2023-06-27 08:21:15 +02:00
Erik Montnemery
9dc586bd98
Use entity registry id in number device actions (#95273) 2023-06-27 08:20:45 +02:00
Erik Montnemery
c2457b8574
Use entity registry id in cover device actions (#95269) 2023-06-27 08:20:05 +02:00
Erik Montnemery
3635508a08
Use entity registry id in vacuum device actions (#95275) 2023-06-26 23:21:15 +02:00
Erik Montnemery
320003bf15
Use entity registry id in lock device actions (#95272) 2023-06-26 23:09:26 +02:00
Erik Montnemery
4efe217d9b
Use entity registry id in select device actions (#95274) 2023-06-26 22:29:14 +02:00
Erik Montnemery
9b1b0937eb
Use entity registry id in button device actions (#95267) 2023-06-26 22:22:15 +02:00
Erik Montnemery
89c9e72768
Use entity registry id in alarm_control_panel device actions (#95241) 2023-06-26 16:59:43 +02:00
Erik Montnemery
a338e7e242
Use entity registry id in toggle_entity device automations (#94995)
* Use entity registry id in toggle_entity device automations

* Update tests

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-06-26 09:59:01 +02:00
Erik Montnemery
af97857c87
Teach select device trigger about entity registry ids (#94981) 2023-06-21 14:51:39 +02:00
Erik Montnemery
ef68f2c3ff
Add empty config schema to integrations d-h (#93645) 2023-05-29 21:00:08 +02:00
J. Nick Koston
ead761dfa2
Ensure device_automation can handle RequirementsNotFound (#92037) 2023-04-26 18:43:38 +02:00
Erik Montnemery
d90ee85118
Allow conditions to be implemented in platforms (#88509)
* Allow conditions to be implemented in platforms

* Update tests

* Tweak typing

* Rebase fixes
2023-02-23 22:30:51 -05:00
Erik Montnemery
6d9411b8a1
Improve trigger platform typing (#88511)
* Improve trigger platform typing

* Tweak docstring

* Revert "Tweak docstring"

This reverts commit c31f790fc3.

* Tweak docstring
2023-02-22 11:59:53 +01:00
J. Nick Koston
d8ee60ee44
Change DeviceAutomationDetails to use a dataclass for py3.11 (#88087)
A NamedTuple can no longer be an enum value in py3.11
2023-02-14 10:22:57 -05:00
Erik Montnemery
87420e949d
Sort manifests 2 (#87023) 2023-02-08 20:16:39 +01:00
Marc Mueller
40be2324cc
Update Union typing (5) [Py310] (#86428) 2023-01-23 09:06:26 +01:00
Erik Montnemery
1e2f00e186
Improve device automation validation (#86143) 2023-01-21 00:44:17 +01:00
Marc Mueller
8f7aca7b69
Update pydocstyle to 6.2.3 (#85449) 2023-01-09 00:59:07 +02:00
Erik Montnemery
774ebc760c
Ignore certain device trigger validation errors (#83972) 2022-12-14 16:41:11 +01:00
Erik Montnemery
1a274adc28
Add config_entries.async_wait_component (#76980)
Co-authored-by: thecode <levyshay1@gmail.com>
2022-11-17 21:52:57 +01:00
Erik Montnemery
43091a9856
Revert "Improve device_automation trigger validation" (#79778)
Revert "Improve device_automation trigger validation (#75044)"

This reverts commit 55b036ec5e.
2022-10-07 08:23:53 -04:00
Franck Nijhof
2b27cfdabb
Set system & entity integration types (#79593) 2022-10-04 10:36:42 -04:00
Ben Randall
55b036ec5e
Improve device_automation trigger validation (#75044)
* improve device_automation trigger validation

Validates the trigger configuration against the device_trigger schema before trying to access any of the properties in order to provide better error messages.
Updates the error message to include an explicit indication that the error is coming from a trigger configuration.  The inner error message from the validator can be accessed by viewing the stack trace.
Add test case for trigger missing domain.

Make action and condition validation consistent with trigger.  This is not strictly necessary, but should be helpful for certain use cases that bypass some of the outer validation.

Removed redundant schema elements from humidifier device_trigger.

**Blueprint with missing `domain`**
```
2022-07-12 06:02:18.351 ERROR (MainThread) [homeassistant.setup] Error during setup of component automation
Traceback (most recent call last):
  File "/workspaces/core/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
  File "/workspaces/core/homeassistant/components/automation/__init__.py", line 241, in async_setup
    if not await _async_process_config(hass, config, component):
  File "/workspaces/core/homeassistant/components/automation/__init__.py", line 648, in _async_process_config
    await async_validate_config_item(hass, raw_config),
  File "/workspaces/core/homeassistant/components/automation/config.py", line 74, in async_validate_config_item
    config[CONF_TRIGGER] = await async_validate_trigger_config(
  File "/workspaces/core/homeassistant/helpers/trigger.py", line 59, in async_validate_trigger_config
    conf = await platform.async_validate_trigger_config(hass, conf)
  File "/workspaces/core/homeassistant/components/device_automation/trigger.py", line 67, in async_validate_trigger_config
    hass, config[CONF_DOMAIN], DeviceAutomationType.TRIGGER
KeyError: 'domain'
```

**Blueprint with missing `property` (specific to zwave_js event schema)**
```
2022-07-12 06:09:54.206 ERROR (MainThread) [homeassistant.components.automation] Blueprint Missing Property generated invalid automation with inputs OrderedDict([('control_switch', '498be56d796836a67406e9ad373d23db')]): required key not provided @ data['property']. Got None
```

**Blueprint with missing `domain`**
```
2022-07-12 06:12:16.080 ERROR (MainThread) [homeassistant.components.automation] Blueprint Missing Domain generated invalid automation with inputs OrderedDict([('control_switch', '498be56d796836a67406e9ad373d23db')]): invalid trigger configuration: required key not provided @ data['domain']. Got <homeassistant.components.blueprint.models.BlueprintInputs object at 0x7f581e097820>
```

**Blueprint with missing `property` (specific to zwave_js event schema)**
```
2022-07-12 06:12:16.680 ERROR (MainThread) [homeassistant.components.automation] Blueprint Missing Property generated invalid automation with inputs OrderedDict([('control_switch', '498be56d796836a67406e9ad373d23db')]): invalid trigger configuration: required key not provided @ data['property']. Got <homeassistant.components.blueprint.models.BlueprintInputs object at 0x7f581c0dc9d0>
```

* Revert humifidier TRIGGER_SCHEMA change.
2022-10-03 16:42:57 +02:00
epenet
17e217269f
Expose device_automation constants in root (#78266) 2022-09-12 18:39:07 +02:00
epenet
253d355526
Remove unused mypy ignore statements (#78292) 2022-09-12 09:25:11 -04:00
Marc Mueller
e39672078d
Use TriggerActionType [core, d-h] (#76804) 2022-08-15 17:39:14 +02:00
J. Nick Koston
57b63db567
Improve typing for device_automation (#74282) 2022-07-01 01:23:00 -05:00
epenet
fe1c3d3be8
Revert "Allow non-async functions in device automation (#72147)" (#72909) 2022-06-02 23:00:47 -07:00
epenet
c2fdac2014
Allow non-async functions in device automation (#72147)
* Remove async requirement for get_capabilities_func

* Add comment

* Remove async requirement for get_automations_func

* Update homeassistant/components/device_automation/__init__.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/components/device_automation/__init__.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Add Exception to type hint

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-06-02 09:06:22 +02:00
epenet
5cfb31d28a
Adjust device_automation type hints in core components (#72207) 2022-05-23 16:07:34 +02:00
epenet
421167c548
Drop GetAutomationsResult and GetAutomationCapabilitiesResult aliases (#72328) 2022-05-23 12:18:17 +02:00