I have this script that uses a response_variable to return information to a conversation agent. When the CA is executing the script it says that the requested information is not available. Looking at the traces the response_variable only contains this:
stop: null
error: false
but no further data. But input_text.now_playing contains the expected data.
This is the script:
now_playing_on_ma:
alias: "Get Now Playing Track Name from MA"
description: 'This script is used to get the current playing song in Music Assistant based on a voice request.
The tool requires no arguments. Use this tool whenever the user requests title or song information for
the currently plying title on music assistant.'
mode: queued
sequence:
- action: music_assistant.get_queue
data:
entity_id: media_player.receiver
response_variable: queue_info
- service: input_text.set_value
data:
entity_id: input_text.now_playing
value: '{{ queue_info["media_player.receiver"].current_item.name[:50] }}'
- variables:
response: |
{% set nowplaying = states("input_text.now_playing") %}
{{ {"title": nowplaying} }}
- stop:
response_variable: response
Thanks Jack, unfortunately this does not work for me. The CA is executing the script and input_text.now_playing is set correctly but still the CA answer is wrong.
OK, I have simplified my script to a minimum but still no success:
now_playing_on_ma:
alias: "Get Now Playing Track Name from MA"
description: 'This script is used to get the current playing song in Music Assistant based on a voice request.
The tool requires no arguments. Use this tool whenever the user requests title or song information for
the currently playing title on music assistant.'
mode: queued
sequence:
- variables:
response: |
'{"title": "Song from Band"}'
- stop: ''
response_variable: response
Dunno why your previous attempts failed, but the last one is obvious – a response variable must always contain a dict / mapping while you are passing a string.
The “minimum” to test with would be this:
- variables:
response:
title: Song from Band
- stop:
response_variable: response