I am trying to create an overloaded custom sentence that will automatically pass the area of the voice assistant activated if not specified. Is it possible to create a sentence of the form:
"Play CBC radio [[on|in] {media_player}]"
In this case, if the sentence “play cbc radio” is picked up by a voice assistant with a defined area, then the intent_script would be passed the area and the corresponding media_player would be used. If the sentence “play cbc radio in kitchen” is picked up, the kitchen media_player would be used.
For completeness, here are my 2 .yaml files:
custom_sentences:
intents:
SetVolume:
data:
- sentences:
- "(set|change|increase|decrease) <media_player> volume to {volume} [(percent|%)]"
- "Turn <media_player> volume (up|down) to {volume} [(percent|%)]"
- "((set|change|increase|decrease) the volume to {volume} [(percent|%)];[on ]<media_player>)"
- "(Turn the volume (up|down) to {volume} [(percent|%)];[on ]<media_player>)"
- sentences:
- "(set|change|increase|decrease) [the] volume to {volume} [(percent|%)]"
- "Turn [the] volume (up|down) to {volume} [(percent|%)]"
slots:
domain: "media_player"
requires_context:
area:
slot: true
intent_script:
SetVolume:
action:
service: "media_player.volume_set"
data:
entity_id: "{{ media_player }}"
volume_level: "{{ volume / 100.0 }}"
speech:
text: "Volume set to {{ volume }} percent"
but I get this error
2024-02-03 22:14:39.695 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'media_player' is undefined when rendering '{{ media_player }}'
2024-02-03 22:14:39.699 ERROR (MainThread) [homeassistant.helpers.script.intent_script_setvolume] Intent Script SetVolume: Error executing script. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data['entity_id']
2024-02-03 22:14:39.700 WARNING (MainThread) [homeassistant.helpers.intent] Received invalid slot info for SetVolume: not a valid value for dictionary value @ data['entity_id']
So perhaps the core doesn’t support the media_player domain yet?
Have you had any luck getting area populated for non media_players?
Trying to get the heating to fire in a specific room when I say that I’m cold.
I’m just getting a long alpha-numeric string read out as the area. This appears to be the area ID, but using area.name results in nothing in the speech text. Using area.attributes.name returns ‘An unexpected error occurred’.
BoostRoomHeating:
speech:
text: "Turning on heating in {{ area }}"
action:
- service: input_boolean.turn_on
target:
entity_id: "input_boolean.boost_{{ area }}"
I love progress! Now to play with it some more so I can either call for a specific player or the area will be recognised but have it all in one intent. BTW the search is used to find the music assistant player as I have prefixed all their entity ids with ma_