SpotifyPlus Integration

@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.

1 Like

Hi,

Is it possible to hide the media-browser-control-filter?

@woempiej
Unfortunately no, not at this time.

1 Like

Hi @thlucas - thanks for all your work on this by the way :slightly_smiling_face:

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?

Many thanks

1 Like

@joehmdeegan
Unfortunately, this is a Sonos limitation

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 :slight_smile: 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.

Anyway, glad you found a workaround.

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 :slightly_smiling_face:

Thanks for help and info!

1 Like

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?

1 Like

@tormodnt
SpotifyPlus author here … what problems/ errors are you seeing with SpotifyPlus?

@thlucas Just hit me that there maybe is two different authors, one for SpotifyPlus and another for the SpotifyPlus Card?

I see no problem with SpotifyPlus, and can play Spotify from the SpotifyPlus card, but non of the the other stuff works. Yes I’m Spotify premium.

@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.

When I tried copy/paste it was just as mess.

Maybe this works: https://pastebin.com/U4SNJcrq

@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

Try now, set it to public.

1 Like

@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:

Hope it’s readable. Had to stitch several images.

1 Like

@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.

Here’s the list in text format.

/hacsfiles/actions-card/actions-card.js?hacstag=972790285162
/hacsfiles/apexcharts-card/apexcharts-card.js?hacstag=331701152223
/hacsfiles/battery-state-card/battery-state-card.js?hacstag=256292682321
/hacsfiles/better-thermostat-ui-card/better-thermostat-ui-card.js?hacstag=439367892221
/hacsfiles/Bubble-Card/bubble-card.js?hacstag=680112919310
/hacsfiles/button-card/button-card.js?hacstag=146194325701
/hacsfiles/calendar-card-pro/calendar-card-pro.js?hacstag=939311749310
/hacsfiles/config-template-card/config-template-card.js?hacstag=172177543136
/hacsfiles/energy-gauge-bundle-card/energy-gauge-bundle-card.js?hacstag=640516976003
/hacsfiles/energy-line-gauge/energy-line-gauge.js?hacstag=926281076227
/hacsfiles/energy-period-selector-plus/energy-period-selector-plus.js?hacstag=639953950023
/hacsfiles/extended-gauge/extended-gauge.js?hacstag=971870393014
/hacsfiles/gauge-card-pro/gauge-card-pro.js?hacstag=963750120200
/hacsfiles/gauge-card/gauge-card.js?hacstag=187245495023
/hacsfiles/ha-today-card/ha-today-card.js?hacstag=934697455111
/hacsfiles/hass-blind-card/hass-blind-card.js?hacstag=402799177104
/hacsfiles/kiosk-mode/kiosk-mode.js?hacstag=497319128902
/hacsfiles/lovelace-auto-entities/auto-entities.js?hacstag=1677445841161
/hacsfiles/lovelace-big-slider-card/big-slider-card.js?hacstag=332589148115
/hacsfiles/lovelace-card-mod/card-mod.js?hacstag=190927524410
/hacsfiles/lovelace-flower-card/flower-card.js?hacstag=297423025202510
/hacsfiles/lovelace-fold-entity-row/fold-entity-row.js?hacstag=150781994232
/hacsfiles/lovelace-hui-element/hui-element.js?hacstag=249942054180547
/hacsfiles/lovelace-layout-card/layout-card.js?hacstag=156434866247
/hacsfiles/lovelace-mushroom-better-sliders/mushroom.js?hacstag=586363416302
/hacsfiles/lovelace-mushroom/mushroom.js?hacstag=444350375509
/hacsfiles/lovelace-navbar-card/navbar-card.js?hacstag=871106499130
/hacsfiles/lovelace-slider-entity-row/slider-entity-row.js?hacstag=1448997001750
/hacsfiles/lovelace-state-switch/state-switch.js?hacstag=158756598196
/hacsfiles/lovelace-vertical-slider-cover-card/vertical-slider-cover-card.js?hacstag=276636213016
/hacsfiles/mass-player-card/mass-player-card.js?hacstag=1043277514250
/hacsfiles/mediocre-hass-media-player-cards/mediocre-hass-media-player-cards.js?hacstag=9446352370280
/hacsfiles/mini-graph-card/mini-graph-card-bundle.js?hacstag=1512800620130
/hacsfiles/mini-media-player/mini-media-player-bundle.js?hacstag=14852083811610
/hacsfiles/modern-circular-gauge/modern-circular-gauge.js?hacstag=8717303430133
/hacsfiles/mushroom-strategy/mushroom-strategy.js?hacstag=619284862250
/hacsfiles/my-cards/my-cards.js?hacstag=399108901106
/hacsfiles/rain-gauge-card/rain-gauge-card.js?hacstag=609593305140
/hacsfiles/rfxtrx-stateful-blinds-icons/rfxtrx-stateful-blinds-icons.js?hacstag=763203701100
/hacsfiles/room-summary-card/room-summary-card.js?hacstag=9192095670630
/hacsfiles/simple-swipe-card/simple-swipe-card.js?hacstag=970744650281
/hacsfiles/simple-timer-card/simple-timer-card.js?hacstag=1044596323211
/hacsfiles/slider-button-card/slider-button-card.js?hacstag=4987940331130
/hacsfiles/spotifyplus_card/spotifyplus_card.js?hacstag=8764888741068
/hacsfiles/stack-in-card/stack-in-card.js?hacstag=248954055020
/hacsfiles/swipe-card/swipe-card.js?hacstag=192732887500
/hacsfiles/Switch-and-Timer-Bar-Card/switch-and-timer-bar-card.js?hacstag=1013376180108
/hacsfiles/TimeFlow-Card/timeflow-card.js?hacstag=102230755432
/hacsfiles/timer-bar-card/timer-bar-card.js?hacstag=3769045171311
/hacsfiles/vertical-stack-in-card/vertical-stack-in-card.js?hacstag=142051833101
/hacsfiles/week-planner-card/week-planner-card.js?hacstag=7717287661141
/hacsfiles/yet-another-media-player/yet-another-media-player.js?hacstag=9991772983300
https://github.com/Prosono/Drag-And-Drop-Card

@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.

Duplicate Resource List

- /hacsfiles/apexcharts-card/apexcharts-card.js
- /hacsfiles/battery-state-card/battery-state-card.js
- /hacsfiles/Bubble-Card/bubble-card.js
- /hacsfiles/button-card/button-card.js
- /hacsfiles/calendar-card-pro/calendar-card-pro.js
- /hacsfiles/config-template-card/config-template-card.js
- /hacsfiles/kiosk-mode/kiosk-mode.js
- /hacsfiles/lovelace-auto-entities/auto-entities.js
- /hacsfiles/lovelace-card-mod/card-mod.js
- /hacsfiles/lovelace-fold-entity-row/fold-entity-row.js
- /hacsfiles/lovelace-layout-card/layout-card.js
- /hacsfiles/lovelace-mushroom/mushroom.js
- /hacsfiles/lovelace-navbar-card/navbar-card.js
- /hacsfiles/lovelace-state-switch/state-switch.js
- /hacsfiles/mass-player-card/mass-player-card.js
- /hacsfiles/mediocre-hass-media-player-cards/mediocre-hass-media-player-cards.js
- /hacsfiles/mini-graph-card/mini-graph-card-bundle.js
- /hacsfiles/mini-media-player/mini-media-player-bundle.js
- /hacsfiles/room-summary-card/room-summary-card.js
- /hacsfiles/simple-swipe-card/simple-swipe-card.js
- /hacsfiles/spotifyplus_card/spotifyplus_card.js
- /hacsfiles/stack-in-card/stack-in-card.js
- /hacsfiles/swipe-card/swipe-card.js
- /hacsfiles/vertical-stack-in-card/vertical-stack-in-card.js

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).


1 Like