spotcast icon indicating copy to clipboard operation
spotcast copied to clipboard

Strange behaviour of spotcast.start when invoked from intent_script

Open popeating opened this issue 7 months ago • 2 comments

i made an Alexa custom skill to manage different things on my Home Assistant one of the skill should reproduce a spotify playlist on a device (via spotcast) the skill will invoce an intent_script passing the playlist and the device so that a phrase like "play {{playlist}} on {{name}}" should trigger the execution of the playlist this is my intent_script related to the action i want to trigger:

AltaRotazione:
  action:
    - service: notify.persistent_notification
      data:
        message: "{{playlist}} su {{name}}"
    - service: spotcast.start
      data:
        device_name: "{{name}}"
        random_song: true
        uri: >-
          {% if playlist == "Jazz In Cucina" %}
            spotify:playlist:37i9dQZF1DX55mNLGdHona
          {% elif playlist == 'Alta Rotazione'%}
            spotify:playlist:37i9dQZF1DX01NP73ErE8b
          {% elif playlist == 'Hot Hits Italia'%}
            spotify:playlist:37i9dQZF1DX6wfQutivYYr
          {% elif playlist == 'In Tendenza'%}
            spotify:playlist:37i9dQZF1DX0ckkFHFOpuK
          {% elif playlist == 'French Jazz'%}
            potify:playlist:37i9dQZF1DXbehaqJzJXqw
          {% elif playlist == 'Jazzy Dinner'%}
            spotify:playlist:37i9dQZF1DWTALrdBtcXjw
          {% endif %}
  speech:
    text: >
      {{ [
        "OK eseguo " ~ playlist + " su " ~ name + "",
        "Certo, faccio partire " ~ playlist + " su " ~ name + "",
        "Eseguo la playlist " ~ playlist + " su " ~ name + "",
        "OK, playlist " ~ playlist + " è in esecuzione su " ~ name + ""
      ] | random }}

It works correctly (the right playlist start on the right device), but Alexa get in return an error instead that saying whats in the speech:

"request": {
		"type": "SessionEndedRequest",
		"requestId": "amzn1.echo-api.request.XXXXXXXXXX",
		"timestamp": "2024-07-21T18:19:24Z",
		"locale": "it-IT",
		"reason": "ERROR",
		"error": {
			"type": "INVALID_RESPONSE",
			"message": "An exception occurred while dispatching the request to the skill."
		}
	}

The Alexa skill works correctly with other things (like executing a preset from my device) similar to this one, and if i remove the "action" part in the intent, Alexa send me back the right speech (of course not running the playlist), so it does not look like a speech error It looks like spotcast.start send back something to the skill before the speech any suggestion?

popeating avatar Jul 21 '24 18:07 popeating