I’m trying to make HA load my YAML file with the following custom sentences:
language: "en"
intents:
PlayRadio:
data:
- sentences:
- "Play {radio_station} on {media_player}"
- "Start {radio_station} on {media_player}"
- "Turn on {radio_station} on {media_player}"
slots:
radio_station:
type: list
values:
NRK P1: "7b1266f2-da4f-47a9-9f50-d689a8d64d3f"
NRK P2: "e17c1cd7-12a1-40b1-a12a-6d8bcf7dc6d8"
NRK P3: "f3aefc9d-35e1-41aa-bf3f-88d55ff1b21a"
media_player:
type: list
values:
Ema speaker: "media_player.ema_speaker"
Nabu speaker: "media_player.home_assistant_voice_094fea_media_player"
Solarium speaker: "media_player.solarium_speaker"
The file path is /homeassistant/custom_sentences/en/radio_sentences.yaml
But all my attempts to make this work always result in the following error in the log:
hassil.errors.MissingListError: Missing slot list
I haven’t found any clear documentation on the correct syntax for such custom sentence YAML files, so there could be as simple as incorrect syntax or indents, but I’ve tried everything possible that I could think of. I’ve also tried asking AI, but they just hallucinate wildly.
Please help.
Oh, one last question; Is it really necessary to restart Home Assistant every time I make a change to the custom sentence YAML file? Or is it sufficient to reload all yaml configuration ?
Yes, I believe you are structuring your slots wrong, based on the documentation.
I don’t fully understand the documentation, but it appears that slots are defined separately from their lists, and should use an “in/out” syntax to convert something like “NRK P1” into the value you want.
Then that’s exactly the response I get. But when using the text string shown in the file, I get the error message: An unexpected error occurred.
If I instead put:
speech:
text: "Playing {{ radio_station }} on {{ media_player }}"
Then the response is:
Playing 7b1266f2-da4f-47a9-9f50-d689a8d64d3f on media_player.ema_speaker
So obviously, my problem is that I need to figure out how to retrieve the spoken word. Now it uses the “out:” value and it seems to have completely forgotten the “in:” value.
The out value is the only thing the intent_script receives. Also the slot variable is not sent to the intent_script.
That’s why I use the response and not the speech option in the intent_script
But only if I write the command sentence to Assist using my keyboard.
If I try to speak the command, the intent script seems to be completely missed or ignored.
@TheFes
I’ve made it much furter, and so far everything work perfectly in both English and Norwegian (my language)
But now I wanted to make the intent_script fall back to a default media_player if none is specified in the parsed sentence.
That seems much more difficult than i had anticipated.
You need to wrap it in quotes if you use the single line notation
# single line notation, quotes required
value_template: "{{ some template }}"
# mult line notation (using >), no quotes required
value_template: >
{{ some template }}
This is because you can also use JSON in YAML, and the { is used in JSON to start a mapping/dictionary.
So without the quotes it will error because it thinks it’s a malformed mapping/dictionary