-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add documentation on triggers yaml #2884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
it is also used on core, in the |
||||||
| 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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
if we update the example class above, I think we can simplify this sentence since it is part of the full example in the current top section. |
||||||
|
|
||||||
| ```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 | ||||||
| ``` | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should adapt this trigger to be more realistic, I'd love for the example YAML to adhere to the example trigger, but from the example it wasn't clear what
event_type: strwas used forThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think we should have a single consistent example on this page. Lets update the class to represent a nicer trigger.