I have an intent script that I use with Alexa where I pick a random playlist to send to a media player. I’d like to have the name of the playlist spoken in the speech:
block of the intent. Is there a way to do that? I tried defining a variables:
block like I’d do in a script, but that doesn’t seem to work. And the scope of a variable in the action:
block is distinct from the speech:
block.
Where is the name of the playlist referenced? I mean is it in a sensor, an attribute of an entity, or what?
The list is in a sensor that updates periodically from an outside source. Currently, in my intent_script, I pick the random playlist in the action:
block where I supply it as the media_content_id
to a play_media
action.
{%- set uris = state_attr('sensor.music_server_playlist_json','uris') %}
{%- set playlist_id = uris | list | random %}
{%- set playlist_name = uris[playlist_id] %}
I guess I could split things up so that the intent updates another sensor and I watch that sensor for a change, but I’d prefer to handle everything inside the media_intent
.
So could you create a template sensor (outside the intent) to hold the playlist name and just say that?
speech:
text: It's {{ states('sensor.playlist_name') }}
I suppose you’d have to pick the playlist outside the intent script as well.
Sure. But I was hoping to handle everything inside the intent_script.