From f3b2d8ad7cd80e40f809bf7a1107727a52fab350 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:53:21 -0400 Subject: [PATCH] Add docs about device condition and action dynamic schema validation (#984) --- docs/device_automation_action.md | 7 +++++++ docs/device_automation_condition.md | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/docs/device_automation_action.md b/docs/device_automation_action.md index 11b8fd60..d53eadf0 100644 --- a/docs/device_automation_action.md +++ b/docs/device_automation_action.md @@ -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: diff --git a/docs/device_automation_condition.md b/docs/device_automation_condition.md index 10f12f17..4d1d4486 100644 --- a/docs/device_automation_condition.md +++ b/docs/device_automation_condition.md @@ -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: