Add docs about device condition and action dynamic schema validation (#984)

This commit is contained in:
Raman Gupta 2021-06-28 17:53:21 -04:00 committed by GitHub
parent 9068b64e55
commit f3b2d8ad7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,13 @@ Device actions are defined as dictionaries. These dictionaries are created by yo
Device actions can be provided by the integration that provides the device (e.g. ZHA, deCONZ) or the entity integrations that the device has entities with (e.g. light, switch).
An example of the former could be to reboot the device, while an example of the latter could be to turn a light on.
If the action requires dynamic validation that the static `ACTION_SCHEMA` can't provide, it's possible to implement an `async_validate_action_config` function.
```py
async def async_validate_action_config(hass: HomeAssistant, config: ConfigType) -> ConfigType:
"""Validate config."""
```
Home Assistant includes a template to get started with device actions. To get started, run inside a development environment `python3 -m script.scaffold device_action`.
The template will create a new file `device_action.py` in your integration folder and a matching test file. The file contains the following functions and constants:

View File

@ -10,6 +10,13 @@ Device conditions are defined as dictionaries. These dictionaries are created by
Device conditions can be provided by the integration that provides the device (e.g. ZHA, deCONZ) or the entity integrations that the device has entities with (e.g. light, humidity sensor).
An example of the latter could be to check if a light is on or the floor is wet.
If the condition requires dynamic validation that the static `CONDITION_SCHEMA` can't provide, it's possible to implement an `async_validate_condition_config` function.
```py
async def async_validate_condition_config(hass: HomeAssistant, config: ConfigType) -> ConfigType:
"""Validate config."""
```
Home Assistant includes a template to get started with device conditions. To get started, run inside a development environment `python3 -m script.scaffold device_condition`.
The template will create a new file `device_condition.py` in your integration folder and a matching test file. The file contains the following functions and constants: