Hi everyone!
Upfront: Thanks to all the great people out here providing support to people like me, who aren’t professional in coding!!
My goal is to control my kodi-tv channels (running on a seperate raspi 3) via voice command.
It already works fine with this simple setup (example for two channels):
In a config/custom_sentences/de/TVchannels.yaml I defined the intents:
#file: config/custom_sentences/de/TVchannels.yaml
language: "de"
intents:
Das Erste:
data:
- sentences:
- "Das Erste"
- "ARD"
Das Zweite:
data:
- sentences:
- "Das Zweite"
- "ZDF"
… and in the configuration.yaml I defined the intents_scripts:
intent_script:
Das Erste:
action:
service: media_player.play_media
data:
media_content_id: "1621"
media_content_type: CHANNEL
target:
entity_id: media_player.raspi3
Das Zweite:
action:
service: media_player.play_media
data:
media_content_id: "1604"
media_content_type: CHANNEL
target:
entity_id: media_player.raspi3
as you can see I use the media_content_id to select the correct channel and it works.
But now I wonder if this could be made more elegant and easier to maintain.
My idea is to use a slot for the spoken TV-channel and somehow map this to the media_content_id. I tried e.g.:
in the TVchannels.yaml:
intents:
channels:
data:
- sentences:
- "Sender {channel}"
- "Kanal {channel}"
lists:
channels:
values:
- in: "(Das Erste | ARD)"
out: "1621"
- in: "(Das Zweite | ZDF)"
out: "1604"
(Side-question: I tried to use the lists:-part directly in the configuration.yaml (not in the TVchannels.yaml, but I got the error: Integration “lists” is not known… would be interesting for me to know why…).
and in the configuration.yaml:
intent_script:
channels:
action:
service: media_player.play_media
data:
media_content_id:
data:
value: "{{slots.channels}}" # <- not sure what belongs here, I tried also trigger.slots.channels
media_content_type: CHANNEL
target:
entity_id: media_player.raspi3
But in many way I tried I get an error about “slots” not defined or “trigger” not defined.
Am I going in the right direction or is there a complete other way to set this up?
Many thanks for advice!
Flo