fondberg / spotcast

Home assistant custom component to start Spotify playback on an idle chromecast device as well as control spotify connect devices
Apache License 2.0
662 stars 94 forks source link

Strange behaviour of spotcast.start when invoked from intent_script #445

Closed popeating closed 2 weeks ago

popeating commented 1 month ago

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?

fcusson commented 1 month ago

@popeating Does the service call runs on its own? Do you have any error in your logs related to spotcast.

fcusson commented 1 month ago

@popeating i also see you removed the whole bug report form to put your own information instead.

I'm not asking that information to be annoying we need it to help you debug. Please don't do that. Can you please reply with the content of that form? Just copy it from a new ticket.

fcusson commented 2 weeks ago

no reply from reporter after asking for complete bug report, closing.