@arrrobase
Based on the get_spotify_connect_device output, it appears the Home speakers (2bf3e489ca91766b277d3d288f35d8d4) device resolved to an IPV6 host address (e.g. HostIpAddress: fe80::4607:bff:fe81:cf12) and not IPV4.
SpotifyPlus tries to use IPV4 to activate these devices, and is failing because it’s an IPV6 address.
The only way to get around that (that I know of) is to disable IPV6 at the router level, or create an IPv4-only SSID and connect your Google cast devices to it.
Hi @thlucas - thanks for all your work on this by the way
I have an issue with being able to play based on context on my sonos speakers.
I added the user id, connect email and password in the service config, and I have created the spotifyplus_tokens.json file correctly and saved it in the .storage folder, but I still cannot get media to play and update the spotify queue (so that the queue updates and can be controlled in Spotify app). Hope you can help? What information can I provide to help you help me? Or is this just not possible to do?
For Sonos devices, all content is played on the device using the local queue when the play context / tracks services are called. The local queue content that is currently playing will be different than what the Spotify Web API is currently reporting as playing. Unfortunately, Spotify developers disabled the ability to play context / tracks under Spotify control for Sonos devices! Note that the official Spotify Apps (Desktop / Web / Mobile) utilize the Spotify Embedded Client to control the device, which does not have these limitations like the Spotify Web API does.
Thanks, that explanation is spot on and sorry i missed it in the docs. I managed to work around it by staging the queue on a non-Sonos Spotify Connect device first, then transferring playback to Sonos.
In my case I had to move the SpotifyWebApiPython_librespot_credentials into .storage, create a dummy Spotify Connect device via Music Assistant (librespot), grab its device ID, and always transfer playback there before calling play_media. That lets Spotify own the queue so it updates properly in the Spotify app. Once the queue exists, I transfer playback to the Sonos device and it plays fine without Sonos creating a local queue.
So as you say it isn’t possible to do this directly on Sonos via the Web API, but with SpotifyPlus and an intermediate Connect device it’s workable! If anyone wants my voice automation let me know I used Ollama to format the voice request like so:
variables:
raw_query: "{{ trigger.slots.search_term }}"
spotify_entity: media_player.spotifyplus_xxxxxx_xxxxxx
dummy_device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sonos_device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
prompt: >-
This request is for internal automation processing.
Do not execute any actions.
Do not call tools.
Do not ask follow-up questions.
Respond with raw JSON only.
You are a music intent classifier.
Given a command like: "{{ raw_query }}"
Return JSON only:
{
"type": "artist" | "album" | "playlist" | "track",
"query": "<clean search term>"
}
Rules:
- Genre, mood, or collection phrases → playlist
- Known performer → artist
- Explicit album → album
- Song title or "by" phrasing → track
Examples:
hilltop hoods → {"type":"artist","query":"Hilltop Hoods"}
jazz classics → {"type":"playlist","query":"Jazz Classics"}
amy winehouse → {"type":"artist","query":"Amy Winehouse"}
hilltop hoods the nosebleed section → {"type":"track","query":"The Nosebleed Section by Hilltop Hoods"}
IMPORTANT:
- JSON only
- No markdown
- No extra text
@joehmdeegan
I think I remember someone else doing something similar, using the Spotify Connect AddOn instead of MA. I wish the Spotify Web API had the same capabilities as their Embedded SDK, but sadly it does not. This functionality used to work a few months ago when using the Spotify Web Player authorization token created from the SP_DC web cookie credentials, but Spotify disabled that.
Hmm yeah connect addon seems lower overheads than running music assistant, think i will use that instead for the dummy connect device.
Yeah its a shame, i moved away from chromecasts due to problems with speakers dropping out of sync and obviously google reliance, and switched to MA+Sonos. Now MA is not usable with Spotify as a provider due to the reliance on librespot and the whole Spotify scrape business limiting accounts and causing upstream librespot issues…
But now i have best of both worlds, we can keep using spotify app for connect, and view the queue, and manipulate and start playback from HA, wife friendly solution
I just can’t get this to work. @joehmdeegan have tried to help, but nothing helps.
I’ve been thinking that maybe I should just try to remove it and start from fresh start.
Is it as simple as just REMOVE both SpotifyPlus and the SpotifyPlusCard from Hacks and all is gone?
@tormodnt
Can you post your SpotifyPlus Card YAML as well please?
I have one other user that is experiencing this issue, and still have not figured out what it is. SpotifyPlus Card issue 88 is opened for him. You might take a look through there and see if anything jumps out. I initially thought it was a caching / cookie issue, but still am not sure as it is not happening for any other users (besides you now). I am leaning toward a conflict with another plugin / dashboard, but not sure on that either.
@tormodnt
I get the following when viewing your PasteBin link: Error, this is a private paste or is pending moderation. If this paste belongs to you, please login to Pastebin to view it.
You can use the 3-slanted ticks to post your YAML in this forum - like so:
```
Paste your text here
This is Line 2
This is Line 3 with 10 spaces starting here: : end of spaces
```
It will render like the following:
Paste your text here
This is Line 2
This is Line 3 with 10 spaces starting here: : end of spaces
@tormodnt
Got it - your YAML looks fine. I even copied / pasted it to my environment, changing the entity: id to my SpotifyPlus integration media player id and it worked fine for me.
In working with the other individual’s issue, it was found that he did not receive the return_response errors when the card was defined on another HA instance. This tells me that there was some sort of resource conflict on the system where it was receiving the errors.
Can you provide a screenshot of the resources that you have defined on your system? We might be able to compare the resources that you have defined with the resource list from the other user and see if there is anything in common that might be causing the issue.
For example, here are the resources I have on my VM dev HA instance:
@tormodnt
Thanks. I will send this to the other person to see what resources he has in common with yours, to see if we can narrow down the possible conflicts.
@tormodnt
I compiled a list of resource entries that were the same between your environment and the other user (see below). I installed all of those resources, and could not reproduce the error after restarting HA.
I’m wondering if it’s the way the dashboard is configured (that contains the SpotifyPlus card) maybe? or is there anything in your configuration.yaml that might be loading a global resource maybe? For example, something that affects all dashboards?
You might try the following, which will create a new (empty) dashboard and add a new SpotifyPlus Card instance. Just want to make sure there are no other card types on the dashboard to interfere (e.g. auto-entities, card-mod, config-template-card, mushroom, mini-graph-card, etc).
Go to Settings \ Dashboards.
click on Add Dashboard button to create a new dashboard.
select new dashboard from scratch - shows add dashboard dialog.
enter new dashboard details:
title = SpotifyTest3
icon = nothing (default value)
url = dashboard-spotifytest3 (default value)
Admin only = false (default value)
Add to sidebar = true (default value)
click Create button to create the new dashboard.
click SpotifyTest3 menu item in left sidebar to select the new dashboard.
click pencil icon in upper right to edit the new dashboard.
click create section in the bottom tile to create a new section.
click the plus (e.g. +) icon under the New Section title - shows the Add to dashboard dialog.
enter spotify in the search cards textbox to filter the available cards list. this should display the SpotifyPlus card picker.
click the SpotifyPlus Card entry to add the card - shows the SpotifyPlus Card Editor UI dialog.
towards the middle left, click on the select an entity* field to select your SpotifyPlus integration instance.
click Save button to save the card.
click done in the upper right to finish editing the dashboard.
it should now display the SpotifyPlus Card instance in the SpotifyTest3 dashboard.
click on the Devices tab in the card footer area (speaker icon, 2nd from left). This should display the available Spotify Connect devices (or the return_response error message if it’s still not working).