From 168274333f7c70410b26a5aca397dab3e12f09bb Mon Sep 17 00:00:00 2001 From: Joostlek Date: Tue, 2 Dec 2025 23:27:01 +0100 Subject: [PATCH 1/2] Add documentation on triggers yaml --- docs/automations.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/automations.md b/docs/automations.md index 26f2f4083f8..2ceb2d55bc1 100644 --- a/docs/automations.md +++ b/docs/automations.md @@ -31,7 +31,9 @@ from homeassistant.helpers.trigger import Trigger, TriggerActionRunner, TriggerC from homeassistant.helpers.typing import ConfigType _OPTIONS_SCHEMA = vol.Schema({ - vol.Required("event_type"): cv.string, + vol.Required("behavior", default="any"): vol.In( + ["first", "last", "any"] + ), }) _CONFIG_SCHEMA = vol.Schema({ @@ -95,4 +97,31 @@ async def async_get_triggers(hass: HomeAssistant) -> dict[str, type[Trigger]]: } ``` +### Trigger schema + +The frontend uses the `triggers.yaml` file to know the structure of the triggers. +This file is similar to `services.yaml`. + +For example, the following snippet shows a trigger that takes a target binary sensor with a specific device class and a select selector with a predefined set of options. + +```yaml +occupancy_cleared: + target: + entity: + domain: binary_sensor + device_class: presence + fields: + behavior: + required: true + default: any + selector: + select: + translation_key: trigger_behavior + options: + - first + - last + - any +``` + + From a13f49a1f433a7f9f3836397cb41c121ed1f9a3b Mon Sep 17 00:00:00 2001 From: Joostlek Date: Mon, 8 Jun 2026 15:29:06 +0200 Subject: [PATCH 2/2] Fix comments --- docs/automations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/automations.md b/docs/automations.md index 2ceb2d55bc1..376728cced9 100644 --- a/docs/automations.md +++ b/docs/automations.md @@ -99,10 +99,10 @@ async def async_get_triggers(hass: HomeAssistant) -> dict[str, type[Trigger]]: ### Trigger schema -The frontend uses the `triggers.yaml` file to know the structure of the triggers. +Triggers should have their description in a `triggers.yaml` file. The description specifies the structure of the triggers and is used by the frontend, for example. This file is similar to `services.yaml`. -For example, the following snippet shows a trigger that takes a target binary sensor with a specific device class and a select selector with a predefined set of options. +The following snippet shows a trigger that takes a target binary sensor with a specific device class and a select selector with a predefined set of options. ```yaml occupancy_cleared: