Revert "Conversation custom sentences (#25844)" (#25867)

This commit is contained in:
Paulus Schoutsen 2023-01-20 08:25:23 -05:00 committed by GitHub
parent 5a680aa95d
commit 5caa8052db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 115 deletions

View File

@ -24,146 +24,79 @@ The conversation integration allows you to converse with Home Assistant. You can
conversation:
```
## Default sentences
By default, a collection of [community contributed sentences](https://github.com/home-assistant/intents/) are supported in a growing [list of languages](https://developers.home-assistant.io/docs/voice/intent-recognition/supported-languages).
In English, you can say things like "turn on kitchen lights" or "turn off lights in the bedroom" if you have an area named "bedroom".
{% configuration %}
intents:
description: Intents that the conversation integration should understand.
required: false
type: map
keys:
'`<INTENT NAME>`':
description: Sentences that should trigger this intent.
required: true
type: list
{% endconfiguration %}
## Adding custom sentences
You can add your own [sentence templates](https://developers.home-assistant.io/docs/voice/intent-recognition/template-sentence-syntax) to teach Home Assistant about new sentences. These sentences can work with the [built-in intents](https://developers.home-assistant.io/docs/intent_builtin/) or trigger a custom action by defining custom intents with the [intent script integration](/integrations/intent_script/).
By default, it will support turning devices on and off. You can say things like "turn on kitchen lights" or "turn the living room lights off". You can also configure your own sentences to be processed. This works by mapping sentences to intents and then configure the [intent script integration](/integrations/intent_script/) to handle these intents.
To get started, create a `custom_sentences/<language>` directory in your Home Assistant `config` directory where `<language>` is the [language code](https://developers.home-assistant.io/docs/voice/intent-recognition/supported-languages) of your language, such as `en` for English. These YAML files are automatically merged, and may contain intents, lists, or expansion rules.
For an English example, create the file `config/custom_sentences/en/temperature.yaml` and add:
{% raw %}
```yaml
# Example temperature.yaml entry
language: "en"
intents:
CustomOutsideHumidity:
data:
- sentences:
- "What is the humidity outside"
```
{% endraw %}
To teach Home Assistant how to handle the custom `CustomOutsideHumidity` intent, create an `intent_script` entry in your `configuration.yaml` file:
Here is a simple example to be able to ask what the temperature in the living room is.
{% raw %}
```yaml
# Example configuration.yaml entry
conversation:
intents:
LivingRoomTemperature:
- What is the temperature in the living room
intent_script:
CustomOutsideHumidity:
LivingRoomTemperature:
speech:
text: "It is currently {{ states("sensor.outside_humidity") }} percent humidity outside."
text: It is currently {{ states.sensor.temperature }} degrees in the living room.
```
{% endraw %}
More complex [actions](/docs/scripts/) can be done in `intent_script`, such as calling services and firing events.
## Adding advanced custom sentences
Sentences can contain slots (marked with curly braces: `{name}`) and optional words (marked with square brackets: `[the]`). The values of slots will be passed on to the intent and are available inside the templates.
## Extending built-in intents
The following configuration can handle the following sentences:
Extending the built-in intents, such as `HassTurnOn` and `HassTurnOff`, can be done as well.
For example, create the file `config/custom_sentences/en/on_off.yaml` and add:
- Change the lights to red
- Change the lights to green
- Change the lights to blue
- Change the lights to the color red
- Change the lights to the color green
- Change the lights to the color blue
{% raw %}
```yaml
# Example on_off.yaml entry
language: "en"
intents:
HassTurnOn:
# Example configuration.yaml entry
conversation:
intents:
ColorLight:
- Change the lights to [the color] {color}
intent_script:
ColorLight:
speech:
text: Changed the lights to {{ color }}.
action:
service: light.turn_on
data:
- sentences:
- "engage [the] kitchen lights"
slots:
name: "kitchen lights"
HassTurnOff:
data:
- sentences:
- "disengage [the] kitchen lights"
slots:
name: "kitchen lights"
rgb_color:
- "{% if color == 'red' %}255{% else %}0{% endif %}"
- "{% if color == 'green' %}255{% else %}0{% endif %}"
- "{% if color == 'blue' %}255{% else %}0{% endif %}"
```
{% endraw %}
Now when you say "engage the kitchen lights", it will turn on a light named "kitchen lights". Saying "disengage kitchen lights" will turn it off.
Let's generalize this to other entities. The built-in `{name}` and `{area}` lists contain the names of your Home Assistant entities and areas.
Adding `{name}` to `config/custom_sentences/en/on_off.yaml`:
{% raw %}
```yaml
# Example on_off.yaml entry
language: "en"
intents:
HassTurnOn:
data:
- sentences:
- "engage [the] {name}"
HassTurnOff:
data:
- sentences:
- "disengage [the] {name}"
```
{% endraw %}
You can now "engage" or "disengage" any entity.
Lastly, let's add sentences for turning lights on and off in specific areas:
{% raw %}
```yaml
# Example on_off.yaml entry
language: "en"
intents:
HassTurnOn:
data:
- sentences:
- "engage [the] {name}"
- sentences:
- "engage [all] lights in [the] {area}"
slots:
name: "all"
domain: "light"
HassTurnOff:
data:
- sentences:
- "disengage [the] {name}"
- sentences:
- "disengage [all] lights in [the] {area}"
slots:
name: "all"
domain: "light"
```
{% endraw %}
It's now possible to say "engage all lights in the bedroom", which will turn on every light in the area named "bedroom".
## Service `conversation.process`
| Service data attribute | Optional | Description |
|------------------------|----------|------------------|
|------------------------|----------|--------------------------------------------------|
| `text` | yes | Transcribed text |
## Service `conversation.reload`
| Service data attribute | Optional | Description |
|------------------------|----------|--------------------------------------------------------------------------|
| `language` | yes | Language to clear intent cache for. Defaults to Home Assistant language. |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB