Commit Graph

92 Commits (cb37df6a619afc167ae758796b8cd980d8e0ee39)

Author SHA1 Message Date
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
epenet 8ef39c3cfd
Add new methods to DeviceAutomationConditionProtocol (#72169)
* Add composite type

* Add new methods to DeviceAutomationConditionProtocol
2022-05-19 18:24:01 +02:00
epenet 8a00281eaa
Add new methods to DeviceAutomationTriggerProtocol (#72168)
* Add composite type

* Add new methods to DeviceAutomationTriggerProtocol
2022-05-19 18:23:40 +02:00
epenet 17bb503450
Add new methods to DeviceAutomationActionProtocol (#72163)
* Add composite type

* Extend action protocol

* Drop return/raise
2022-05-19 18:23:23 +02:00
Franck Nijhof 69cc6ab5f1
Clean up accessing entity_registry.async_get_registry helper via hass (#72005) 2022-05-17 16:40:45 +02:00
Erik Montnemery f859cb6b2e
Remove unneeded bind_hass from device_automation code (#71599) 2022-05-09 23:19:00 +03:00
Erik Montnemery f6d9c75476
Remove metadata from device conditions and triggers (#70695) 2022-04-25 09:48:24 -07:00
Erik Montnemery 5e50a8abd5
Mark device triggers from hidden or auxiliary entities as secondary (#70335)
* Mark device triggers from hidden or auxiliary entities as secondary

* Update tests
2022-04-21 08:01:32 +02:00
Erik Montnemery 150f173eed
Mark device conditions from hidden or auxiliary entities as secondary (#70333) 2022-04-20 21:41:59 +02:00
Erik Montnemery 64381acbaf
Mark device actions from hidden or auxiliary entities as secondary (#70278) 2022-04-20 10:48:46 -07:00
Paulus Schoutsen 824066f519
Device Automation: enforce passing in device-automation-enum (#69013) 2022-03-31 14:30:11 -07:00
Paulus Schoutsen c2e62e4d9f
Re-org device automations (#67064)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-02-22 13:15:16 -08:00
Marc Mueller 1a247f7d1b
Improve `device_automation` typing (#66621) 2022-02-17 22:08:43 +01:00
Erik Montnemery 513d6cc467
Change value of device_automation constant (#64296)
* Change value of constant CONF_CHANGED_STATES

* Adjust tests
2022-01-17 16:34:40 +01:00
Erik Montnemery 3b7448bb1c
Import websocket_api (part 2) (#63906) 2022-01-11 17:26:25 +01:00
Marc Mueller 4d76ed9ceb
Fix implicit reexport [helpers.condition] (#63830) 2022-01-11 11:03:10 +01:00
Franck Nijhof 2fe08d2b9b
Complete strict typing to Humidifier entity platform (#61021) 2022-01-04 18:09:32 +01:00
epenet f7b26e9b06
Fix relative import issue in device_automation (#63274)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-03 11:59:50 +01:00
Erik Montnemery e9b746e874
Add turned on or off device trigger to toggle entity (#61089)
* Add turned on or off device trigger to toggle entity

* Renamed changed_states trigger to toggled

* Adjust tests

* Fix homekit triggers test

* Add tests

* Adjust tests after rebase

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-01-03 10:41:30 +01:00
epenet 6d51cccbf7
Add init type hints [d] (#63101)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-02 16:12:46 +01:00
Ville Skyttä 9b437ef146
Remaining DeviceAutomationType bits (#62508)
* Use DeviceAutomationType in missed tests/components/*

* Tighten device automation type hints
2021-12-21 20:05:48 +02:00
Ville Skyttä 334c6c5c02
Make device automation type an enum (#62354) 2021-12-20 19:16:30 +01:00
Michael b68a2747f3
Use relative imports [A-H] (#61574) 2021-12-13 20:03:01 +01:00
Erik Montnemery 0e3bc21d54
Teach state and numeric_state conditions about entity registry ids (#60841) 2021-12-02 14:55:12 -08:00
Erik Montnemery c85bb27d0d
Teach state trigger about entity registry ids (#60271)
* Teach state trigger about entity registry ids

* Tweak

* Add tests

* Tweak tests

* Fix tests

* Resolve entity ids during config validation

* Update device_triggers

* Fix mistake

* Tweak trigger validator to ensure we don't modify the original config

* Add index from entry id to entry

* Update scaffold

* Pre-compile UUID regex

* Address review comment

* Tweak mock_registry

* Tweak

* Apply suggestion from code review
2021-12-02 14:26:45 +01:00
Erik Montnemery caf5ee2fab
Remove optional validation when creating conditions (#60481) 2021-11-28 14:54:07 +01:00
Paulus Schoutsen 77d02d08bc
Validate device automation capablities WS calls (#58444) 2021-10-26 14:47:07 +02:00
Marc Mueller 12d1dfdaf9
Use assignment expressions 10 (#57791) 2021-10-15 21:36:03 +02:00
Marc Mueller 0700108278
Use NamedTuple for device_automation details (#55697) 2021-09-04 13:42:36 +02:00
Ville Skyttä b10fc89a6b
Automation trigger info type hint improvements (#55402)
* Make automation trigger info a TypedDict

* zwave_js trigger type hint fixes

* Remove redundant automation trigger info field presence checks

* Use async_initialize_triggers in mqtt and tasmota device_trigger tests
2021-09-04 02:25:51 +02:00
Paulus Schoutsen 7111fc47c4
Better handle invalid trigger config (#55637) 2021-09-03 10:15:57 -07:00
Paulus Schoutsen 418d6a6a41
Guard for unexpected exceptions in device automation (#55639)
* Guard for unexpected exceptions in device automation

* merge

Co-authored-by: J. Nick Koston <nick@koston.org>
2021-09-03 09:04:50 -07:00
Ville Skyttä 0095c6baeb
Improve device trigger type hinting (#54907) 2021-08-22 20:32:50 +02:00
Ville Skyttä debc6d632c
Improve device condition type hinting (#54906) 2021-08-20 22:21:40 +02:00
Ville Skyttä 4bb2c6e00f
Improve device action type hinting (#54850)
* Improve device action type hinting

* More precise _async_get_automations type hints

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-08-20 07:13:25 +03:00
J. Nick Koston 4bde4504ec
Add api to device_automation to return all matching devices (#53361) 2021-08-10 14:21:34 -05:00
Erik Montnemery 49bec86dae
Add base schema for triggers (#51727)
* Add base schema for triggers

* Tweak

* Make TRIGGER_BASE_SCHEMA a voluptuous schema

* Make state trigger BASE_SCHEMA a voluptuous schema
2021-06-11 09:51:12 +02:00
Erik Montnemery 76c3058d15
Rename device trigger base schema to DEVICE_TRIGGER_BASE_SCHEMA (#51719) 2021-06-10 19:11:38 +02:00