Document sentence trigger wildcards (#28332)

This commit is contained in:
Michael Hansen 2023-07-27 13:31:02 -05:00 committed by Franck Nijhof
parent 55d5c59a1f
commit f8a684b79c
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 28 additions and 0 deletions

View File

@ -92,6 +92,17 @@ These are the properties available for a [Numeric State trigger](/docs/automatio
| `trigger.to_state` | The new [state object] that triggered trigger. | `trigger.to_state` | The new [state object] that triggered trigger.
| `trigger.for` | Timedelta object how long state has met above/below criteria, if any. | `trigger.for` | Timedelta object how long state has met above/below criteria, if any.
### Sentence
These are the properties available for a [Sentence trigger](/docs/automation/trigger/#sentence-trigger).
| Template variable | Data |
| ---- | ---- |
| `trigger.platform` | Hardcoded: `conversation`
| `trigger.sentence` | Text of the sentence that was matched
| `trigger.slots` | Object with matched slot values
| `trigger.details` | Object with matched slot details by name, such as [wildcards](/docs/automation/trigger/#sentence-wildcards). Each detail contains: <ul><li>`name` - name of the slot</li><li>`text` - matched text</li><li>`value` - output value (see [lists](https://developers.home-assistant.io/docs/voice/intent-recognition/template-sentence-syntax/#lists))</li></ul>
### State ### State
These are the properties available for a [State trigger](/docs/automation/trigger/#state-trigger). These are the properties available for a [State trigger](/docs/automation/trigger/#state-trigger).

View File

@ -939,6 +939,23 @@ The sentences matched by this trigger will be:
Punctuation and casing are ignored, so "It's PARTY TIME!!!" will also match. Punctuation and casing are ignored, so "It's PARTY TIME!!!" will also match.
### Sentence Wildcards
Adding one or more `{lists}` to your trigger sentences will capture any text at that point in the sentence. A `slots` object will be [available in the trigger data](/docs/automation/templating#sentence).
This allows you to match sentences with variable parts, such as album/artist names or a description of a picture.
For example, the sentence `play {album} by {artist}` will match "play the white album by the beatles" and have the following variables available in the action templates:
{% raw %}
- `{{ trigger.slots.album }}` - "the white album"
- `{{ trigger.slots.artist }}` - "the beatles"
{% endraw %}
Wildcards will match as much text as possible, which may lead to surprises: "play day by day by taken by trees" will match `album` as "day" and `artist` as "day by taken by trees".
Including extra words in your template can help: `play {album} by artist {artist}` can now correctly match "play day by day by artist taken by trees".
## Multiple triggers ## Multiple triggers
It is possible to specify multiple triggers for the same rule. To do so just prefix the first line of each trigger with a dash (-) and indent the next lines accordingly. Whenever one of the triggers fires, processing of your automation rule begins. It is possible to specify multiple triggers for the same rule. To do so just prefix the first line of each trigger with a dash (-) and indent the next lines accordingly. Whenever one of the triggers fires, processing of your automation rule begins.