SpotifyPlus Integration

@thlucas

DM’d you with output as I’m unsure what the content contains :open_mouth:

1 Like

@SIW1973
Thanks Simon - I will take a look at it.

I don’t think there’s any sensitive information in there (other than DNS alias names, which are only valid on your local internal network), but one can never be too cautious these days.

I’ll get back to you with my findings.

Thanks again for the assist.

2 Likes

@SIW1973 @Hetoft @rml
FYI - just released a new version of the SpotifyPlus integration

Be sure to check out the SpotifyPlus Card Dashboard as well.

As of v1.0.86, the integration supports Spotify Connect devices that are hosted by Google Chromecast devices. This includes transferring playback to idle Chromecast devices, media control (pause, resume, volume changes, etc), as well as supporting multiple Spotify user accounts (both free and premium accounts, and no Spotcast required).

Note that the device must still be discoverable via Zeroconf / MDNS advertisement in order to be detected (even if it’s idle). If the device is physically powered off, it will NOT be detected.

Some initial setup is required as well - check out the SpotifyPlus Google Chromecast Device Support wiki for more information on that; it basically required the sp_key and sp_dc settings from your browser cookie (similar to Spotcast and other integrations).

[ 1.0.86 ] - 2025/01/22

  • Added support for Google Chromecast devices; see SpotifyPlus Google Chromecast Device Support wiki for how to configure.
  • Moved support for Sonos devices to the underlying spotifywebapiPython package.
  • Removed service player_activate_devices. This method is no longer needed, as devices are automatically resolved / activated now.
  • Removed soco package requirement.
  • Updated underlying spotifywebapiPython package requirement to version 1.0.156.
  • Updated underlying smartinspectPython package requirement to version 3.0.34.
1 Like

Hello,

Is there any reason why I would continue to get this error after uninstallation and deletion of the this custom integration?

  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 537, in handle_manifest_list
    raise int_or_exc
homeassistant.loader.IntegrationNotFound: Integration 'spotifyplus' not found.

@DanGarion
Not sure on that one … it appears to still be referenced somewhere; maybe in a script, automation, configuration setting, or front-end card reference? Sometimes HACS misses things in the uninstall process.

I would also ensure browser cache is cleared, and do a complete reboot.

If that fails, try running a file (case-insensitive) search on the <config>\.storage folder looking for any spotifyplus references.

Hope it helps!

Hello,
I have a question regarding the spotifyplus always on functionality.

First thanks alot for you integration, it is really nice to use.
My setup is: HA latest version on intel mini pc. I have a separate raspberryi3b running with raspotify (wrapper for librespot) running. Most of it works perfectly.
My issue is the always on-functionality, as I want to use only Homeassistant to start Spotify. This doesn’t work if the raspberry pi is inactive.
I am lost at the existing documentation what I need to do. Can you explain or hint which setup I need to follow?
Thanks in advance

1 Like

@Wolf42
Is the problem due to not having the “always on” enabled (e.g. you have to power on / off the player)?

Or is the problem due to the player always being on (like HA Spotify integration)?

As of v1.0.85 (2025/01/09) the “always on” can be toggled on / off via configuration options. Check out the Device Configuration Options - Always On wiki section for more information.

Thanks for the fast reply!

I am not sure what is not working, as the how to guide from the wiki doesnt fit to my setup. I dont know what I need to install where (e.g. I created the webapi credentials.json manually)… I assume I havent dont it properly.
my set up is a spotify premium account (2-3 mobiles using it, raspberry pi with raspotify connected with Jack to an Teufel Amplifier with big speakers).

Regarding the configuration … I have configured the latest version correctly, I think


the raspberry pi is not shutdown, but becomes inactive (in spotify id)…

What is do I need to do in order to ensure that the raspotify id is always available.
the librespot discovery mode I cannot set on the raspberry

@Wolf42
So I am not totally familiar with raspotify, but it should be similar to the spotifyd setup based on documentation (just another librespot client).

librespot Spotify Credentials

I would suggest you start with the SpotifyPlus librespot Device Support wiki docs. This will walk you through the following steps:

  1. use the librespot Credentials Generator to create the librespot authentication credentials.json file, if you don’t already have one cached somewhere in the raspotify configuration.

  2. once you have the librespot credentials.json file, you can then create the SpotifyPlus librespot credentials file that SpotifyPlus uses to access raspotify. This file is basically a copy of the librespot credentials.json file, placed in the HA configuration folder so that the SpotifyPlus integration can access it.

Once the above steps are complete, you should have a file that looks similar to the following in the HA configuration storage path (note file name can be case-sensitive on some operating systems):

<config>\.storage\SpotifyWebApiPython_librespot_credentials.json

{
  "username": "31l77xxxxxxxxxxxxxxxxxxxxxxx",
  "auth_type": 1,
  "auth_data": "QVFET2h6 ... aFp3OHg="
}

SpotifyPlus configuration options

Note that you only need to set the Spotify Connect LoginId value in your SpotifyPlus configuration options; you may not need the username and password values, since the librespot authentication credentials are stored in the SpotifyWebApiPython_librespot_credentials.json file. You only need to specify username and password values if you have other Spotify Connect (non-librespot) devices that require them.

You may not need the turn-on script that you have specified either (e.g. Starte Spotify WZ); not sure though, as I don’t know what the script contains. You normally only need a turn_on script if you have to do other things to prepare your device for playing content (e.g. turn on a receiver, set a receiver output, etc).

Please let me know when you get this running, and I will create a wiki section for raspotify support.

Hope it helps!

I figured it out right after this, it was the saved credentials. :wink:

1 Like

@Wolf42
I was able to install raspotify on my Windows 11 Pro WSL Debian image. I could not get the audio to work, as I did not have something configured correctly. I have gotten spotifyd to work, but it was using Pulse Audio, and raspotify uses Alsa I believe.

The good news is that I was able to make the device appear in my Spotify Connect list of devices. It was also responding to media transport commands (e.g. play, pause, etc), so it was authenticating and communicating with librespot correctly; just wasn’t outputting any sound.

I put together a Device Configuration Options - raspotify section that will hopefully help you in getting your setup working. Please give it a try, and let me know how it works for you.

I would be interested to see how your /etc/raspotify/conf options compare to the options I have listed in the wiki.

Hope it helps!

You are amazing.thank you so much.
I will check it out and come back to you!

here is my conf file without the # lines

LIBRESPOT_QUIET=on
LIBRESPOT_DISABLE_AUDIO_CACHE=on
LIBRESPOT_DISABLE_CREDENTIAL_CACHE=on
LIBRESPOT_ENABLE_VOLUME_NORMALISATION=on
LIBRESPOT_DEVICE="hw:CARD=Headphones,DEV=0" (I use the jack output)
TMPDIR=/tmp

right now it seems to work … but I didnt do anything between the issue and now … and for sure the device wasnt used overnight …
reading now through the raspotify explanation makes sense to me now thanks alot .

will come back after a few days of observation if it was permanently fixed.
the raspotify error list doestn show a lot of issues.

1 Like

How nice to read this! I immediately tried this version, hoping to use it as the only integration.
I updated and restarted, and everything seemed fine… Then I noticed that I couldn’t see the Chromecast devices. I followed the guide and read about the file to create for authentication. I created the file, restarted, and magically, nothing works anymore. I tried recreating the authentication credentials. I already have the dev app on Spotify for both accounts I want to use, and I simply noted down the two numbers, but I don’t understand why Spotcast keeps working while Spotify Plus does not.

At this point, I think it’s best to delete everything and start from scratch. I don’t think removing Spotcast is necessary, right? If you have any other suggestions, they are more than welcome.

1 Like

@Diegocampy
It currently supports cast_type = audio chromecast devices. I have only been able to test this with a Google Nest speaker, so not sure if other devices will work or not.

What kinds of Chromecast devices do you have?

You should not have to remove anything for this to work - just add your Google Chromecast User Credentials to the SpotifyPlus configuration json file.

Thanks for the very prompt reply.
I have an old Chromecast first version and a Chromecast Ultra 4k. I think the problem is not so much with the devices, but with my file that I created, so I’ll give you some more information

If I remove that token file, everything works perfectly again.
I have done several tests, several reboots, I have verified the id which in my strange case remains the name, and not a series of numbers, checked the codes as below but with the saved file, spotify plus no longer works. If I delete the file everything works again.

If it can be useful, this is the location of the file and under my created token file

/homeassistant/.storage/spotifyplus_tokens.json

    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "my_sp_dc",
        "sp_key": "my_sp_key",
        "token_type": "CookieCredentials"
    }
1 Like

@Diegocampy
Is that the only entry in the file? If so, then add the start / end brackets like so (without the <----- comment text):

{  <----- need starting bracket
    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "my_sp_dc",
        "sp_key": "my_sp_key",
        "token_type": "CookieCredentials"
    }
}  <----- need ending bracket

If there are other entries in the file, then add a , after the last entry bracket like so:

{
  {  .... other entry(s) ...
  },  <----- add comma after the bracket
    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "my_sp_dc",
        "sp_key": "my_sp_key",
        "token_type": "CookieCredentials"
    }
}

It’s a standard JSON format file, so JSON formatting rules apply.

You should not have to reboot when making changes to the spotifyplus_tokens.json file.

Do any Chromecast devices show up in your media player source_list?

I did this and the file works:

{
    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "sp_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "token_type": "CookieCredentials"
    }
}

now it’s not clear to me how to compose the file for my second home account

{
    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "sp_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "token_type": "CookieCredentials"
    }
}
{
    "SpotifyWebPlayerCookieCredentials/Shared/newaccount": {
        "sp_dc": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "sp_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "token_type": "CookieCredentials"
    }
}

I’m definitely missing some comma or parenthesis. Sorry for my lack of practicality

{
    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "xxxxxxxxxxxxx",
        "sp_key": "xxxxxxxxxxx",
        "token_type": "CookieCredentials"
    },

    "SpotifyWebPlayerCookieCredentials/Shared/xxxxxxxxx": {
        "sp_dc": "xxxxxxxxx",
        "sp_key": "xxxxxxxxxxxx",
        "token_type": "CookieCredentials"
    }
}

I think this is correct

no none :frowning: maybe I should try while I’m at home to start music on it, I’ll update you when I’m home again.
The token file seems ok, because Spotify Plus now works
No

Please upgrade to v1.0.88; I added more device cast_type values to check for supported Chromecast devices: cast, group. The v1.0.87 was only checking for audio devices (e.g. Google Nest).

Google Chromecast User Credentials

If you have multiple accounts that you want to add (or if there are other token entries in the file), add a comma after the closing } bracket of the final entry and add the new token entry after it.

Using your example that you posted above, your SpotifyPlus Token Cache file would look like this:

{
    "SpotifyWebPlayerCookieCredentials/Shared/diegocampy": {
        "sp_dc": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "sp_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "token_type": "CookieCredentials"
    },
    "SpotifyWebPlayerCookieCredentials/Shared/newaccount": {
        "sp_dc": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "sp_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "token_type": "CookieCredentials"
    }
}

Thanks for letting me know, I don’t understand why hacs doesn’t detect any updates anymore

Work!!
image

now spotcast no longer works, but it certainly has nothing to do with Spotify plus. Now I’m starting to try to understand if I can move all my automations to spotify plus, to avoid using spotcast and be able to abandon it :wink:
Thanks for everything

1 Like