Using Assist with Spotify integration, search

I know this an old post but I have an isssue.

Following these instructions all of the intents work fine except for the the first “Spotify” intent.

The sentance parser shows it matches but I get an error on extra keys and invalid slots.

Command “Play Hurt by Johnny Cash on Basement Sonos”

From sentence parser.

intent:
  name: Spotify
slots:
  media_search: 'hurt by johnny cash '
  media_player: basement sonos
details:
  media_search:
    name: media_search
    value: 'hurt by johnny cash '
    text: 'hurt by johnny cash '
  media_player:
    name: media_player
    value: media_player.basement_sonos_2
    text: basement sonos
targets: {}
match: true
sentence_template: Play {media_search} on {media_player}
unmatched_slots: {}
source: custom
file: en/media.yaml

Error in assistant

Errors in Home Assistant Core

 File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 382, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['search']

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1017, in recognize_intent
    conversation_result = await conversation.async_converse(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/agent_manager.py", line 110, in async_converse
    result = await method(conversation_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/entity.py", line 47, in internal_async_process
    return await self.async_process(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 366, in async_process
    intent_response = await intent.async_handle(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/intent.py", line 146, in async_handle
    raise InvalidSlotInfo(f"Received invalid slot info for {intent_type}") from err
homeassistant.helpers.intent.InvalidSlotInfo: Received invalid slot info for Spotify

I am not sure if things changed in a year but SpotCast does not appear to have changed and I have even tried hard coding the “media_search” to the data element “search:” variable in the intent_script and I still get the error.

I have searched similar errors on “extra keys” and “slots” and found nothing helpful.

I tested a simple notify.norify intent and it is picking up everything as I expect it to work, but I still get the error.

Any help on would be helpful.

This might be the issue with the somewhat undisclosed changes to the SpotCast action parameters (the project’s README really needs an update…).

Previously, the integration accepted a generic search prop. However, as of release 3.8.0, they removed that (not sure why that wasn’t a cause for a bump to 4.x since it was a breaking change). Instead of search you now need to use specific fields for each “type” of search you want to do (you can see Improved search functionality - redux by Fripplebubby · Pull Request #423 · fondberg/spotcast · GitHub for the PR that broke the old functionality). The new fields are all suffixed with _name, e.g. artist_name, track_name, genre_name, etc.

It does make it more difficult to perform a general search, since you now need to try and figure out, in the intent handling logic, which placeholder corresponds to which search field. I believe the use-case by the PR’s author was AI-based, so for them, the LLM performed the hard part of trying to figure out what parts of a particular query are the artist, album, song title, etc.

Without the use of AI, I think you need to make more structured sentence triggers, like “play the artist {artist_name} on {device}”. Perhaps there are better ways to handle this without having to start using an LLM, but that was my quick fix for this breakage.

1 Like