I’m very new to HASS, and am fiddling around with intents.
I’m trying to have it play music titles using youtube music. I was able to get this to work by building a custom integration, then an automation that matches on fixed sentene structures. I can add multiple sentences, but I wanted to have it match more loosely, so I give it a coupe example sentences and the llm (in my case Google Generative AI) will match it with the intent.
So I created the following media.yaml file in ./homeassistant/custom_sentences/en
:
language: "en"
intents:
PlayTitle:
data:
- sentences:
- "Play {title} on YouTube Music"
- "Play the song {title} on YouTube Music"
- "Can you play the song {title} on YouTube Music"
- "Get the song {title} on YouTube Music"
- "I want to listen to the song {title} on YouTube Music"
# more examples...
slots:
domain: "title"
requires_context:
area:
slot: true
lists:
title:
wildcard: true
Then I created ./intent_scripts.yaml
PlayTitle:
description: "Play a song on YouTube Music"
action:
- service: youtube_music.play_song
data:
title: "{{ title }}"
speech:
text: "Playing the song {{ title }} on YouTube Music."
And my configuration.yaml looks like this
...
ytmusic:
conversation:
intent_script: !include intent_scripts.yaml
ytmusic is my custom integration.
So I tested it out by saying something like “Can you start {title} on Youtube Music?”, and the agent replies that it’s playing, but in the logs console I just see this
Template variable warning: 'title' is undefined when rendering '{{ title }}'
Template variable warning: 'title' is undefined when rendering 'Playing the song {{ title }} to Youtube Music.'
I’ve really been struggling having my intent_script get access to the title. Does anyone have any suggestions or advice?