SpotifyPlus Custom Integration

Is there a way to implement it to the new ha music Assistent?

@stephanschleichstr13
Not sure on that, as I do not use Music Assistant.

You might reach out to the Music Assistant author (Marcel van der Velt?) via their home page team member list.

Also, it appears that the DJ item in the playlist might still be in BETA stage, as I see beta mentioned in the Spotify home page.

Hope it helps!

1 Like

FYI - just released a new version of the SpotifyPlus integration .

Note - If you are using the SoundTouchPlus integration, you will also need to update it as well since it uses the underlying Spotify Web API Python library.

[ 1.0.38 ] - 2024/06/27
  • Corrected various services that use float values that were incorrectly defined as strings by the service schema.
  • Updated underlying spotifywebapiPython package requirement to version 1.0.71.
[ 1.0.36 ] - 2024/06/26
  • Added support for Spotify Connect LoginID specification in configuration options.
  • Updated underlying spotifywebapiPython package requirement to version 1.0.69.
[ 1.0.33 ] - 2024/06/25
  • Updated underlying spotifywebapiPython package requirement to version 1.0.66.
  • The underlying spotifywebapiPython update changes the way the Spotify Connect Zeroconf API processes the status and spotifyError response values. Some Spotify Connect devices return them as strings, while other return them as numerics. Spotify Zeroconf API specifically says they should be returned as integer values.
[ 1.0.32 ] - 2024/06/25
  • Updated underlying spotifywebapiPython package requirement to version 1.0.65.
  • The underlying spotifywebapiPython update changes the way the Spotify Connect Zeroconf API addUser call is processed to account for “ERROR-INVALID-PUBLICKEY” statuses returned for some devices. This will retry the connection request with the PublicKey value returned from the initial request.
1 Like

Hi, question/possible feature request:

Any possibility of adding support for Spotify Canvas animations/videos?

Currently I have a simple magicmirror dashboard on my desk that uses the magicmirror MMM-OnSpotify plugin to show what’s playing, where its playing, etc that also shows Spotify canvas’es when they are available for a track as seen in the screenshot (not video, sorry) here:

unfortunately, due to magicmirror development dying out, plugins often breaking, etc, I’ve decided a custom dashboard on my home assistant setup might make more sense as a replacement. Currently trying to replicate the MM setup as 1:1 as possible in the new dashboard, but noticed no one’s added canvas support like MMM-OnSpotify has - obviously not breaking anything if I have to always just see album art, but would certainly be a nice to have!

Thoughts? Thanks!

@Rapscallion
I am not familiar with Spotify Canvas, and have not seen anything in the Spotify Web API related to it. It sounds like it’s something more geared to front-end type of development maybe?

With that said, do the video links show up anywhere in the Spotify Web API data? If so, I might be able to add the link as an attribute at least which would allow a front end plugin to access it more easily.

Can you provide a Spotify URI value (e.g. spotify:track:xxxxx) for a track that has associated canvas information? I can take a look to see if it has any canvas related data coming back from the API.

I’m not a developer so I can’t speak to the web API etc, and not sure how MMM-OnSpotify obtains it, but here are URI’s for 2 tracks that have canvas data/vids/animations:

spotify:track:5UWwZ5lm5PKu6eKsHAGxOk
spotify:track:5gRcv46AMTrosmTOqrOV3Q

I did see on the onspotify github, ( https://github.com/Fabrizz/MMM-OnSpotify) they did mention this regarding the canvases:

|experimentalCanvas - Shows the Spotify Canvas if available. This is an experimental feature, as this API is not documented and private.|

Additionally, if you’re personally unfamiliar with canvas, a great way to see it first hand is using any updated iOS or android mobile version of spotify with the 2 example tracks and the player should just automatically load them on playback with no interaction/changes to settings/etc needed

Great! This is a new development as calling the DJ as a playlist never used to work. My uri is different than yours but I guess that makes sense.

1 Like

@Rapscallion
I was able to see the canvas on my Spotify mobile player, so I understand what you are trying to view. The canvas video loop was not shown on my Spotify desktop player.

I was hoping to see something in the external_urls section of the track information for the canvas object, but no luck.

I do see a reference to a https://spclient.wg.spotify.com/canvaz-cache/v0/canvases url that looks like it queries some sort of canvas API.

I don’t think this is currently supported by the Spotify Web API, nor in a Spotify Canvas API (at least not published yet) so nothing I can do at this time.

Sorry.

Track Info

{
  "album": {
    "album_type": "album",
    "artists": [
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/7jy3rLJdDQY21OgRLCZ9sD"
        },
        "href": "https://api.spotify.com/v1/artists/7jy3rLJdDQY21OgRLCZ9sD",
        "id": "7jy3rLJdDQY21OgRLCZ9sD",
        "name": "Foo Fighters",
        "type": "artist",
        "uri": "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD"
      }
    ],
    "external_urls": {
      "spotify": "https://open.spotify.com/album/30ly6F6Xl0TKmyBCU50Khv"
    },
    "href": "https://api.spotify.com/v1/albums/30ly6F6Xl0TKmyBCU50Khv",
    "id": "30ly6F6Xl0TKmyBCU50Khv",
    "images": [
      {
        "url": "https://i.scdn.co/image/ab67616d0000b2730389027010b78a5e7dce426b",
        "width": 640,
        "height": 640
      },
      {
        "url": "https://i.scdn.co/image/ab67616d00001e020389027010b78a5e7dce426b",
        "width": 300,
        "height": 300
      },
      {
        "url": "https://i.scdn.co/image/ab67616d000048510389027010b78a5e7dce426b",
        "width": 64,
        "height": 64
      }
    ],
    "name": "The Colour And The Shape",
    "release_date": "1997-05-20",
    "release_date_precision": "day",
    "total_tracks": 14,
    "type": "album",
    "uri": "spotify:album:30ly6F6Xl0TKmyBCU50Khv"
  },
  "artists": [
    {
      "external_urls": {
        "spotify": "https://open.spotify.com/artist/7jy3rLJdDQY21OgRLCZ9sD"
      },
      "href": "https://api.spotify.com/v1/artists/7jy3rLJdDQY21OgRLCZ9sD",
      "id": "7jy3rLJdDQY21OgRLCZ9sD",
      "name": "Foo Fighters",
      "type": "artist",
      "uri": "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD"
    }
  ],
  "disc_number": 1,
  "duration_ms": 250546,
  "explicit": false,
  "external_ids": {
    "isrc": "USRW29600011"
  },
  "external_urls": {
    "spotify": "https://open.spotify.com/track/5UWwZ5lm5PKu6eKsHAGxOk"
  },
  "href": "https://api.spotify.com/v1/tracks/5UWwZ5lm5PKu6eKsHAGxOk",
  "id": "5UWwZ5lm5PKu6eKsHAGxOk",
  "is_local": false,
  "name": "Everlong",
  "popularity": 84,
  "preview_url": "https://p.scdn.co/mp3-preview/78fd3872e0fa5940b2a36654f07f11e7119be4e2?cid=cfe923b2d660439caf2b557b21f31221",
  "track_number": 11,
  "type": "track",
  "uri": "spotify:track:5UWwZ5lm5PKu6eKsHAGxOk"
}
2 Likes

kinda figured that might be the case, suppose I was just hoping someone might’ve figured out the same magic the MMM-OnSpotify folks did or how they did it in their github source, the canvas just looks so good on the MM dashboard on my pi, suppose I’ll have to just deal with covers again. Thanks for checking it out though!

1 Like

FYI - just released a new version of the SpotifyPlus integration .

Note - If you are using the SoundTouchPlus integration, you will also need to update it as well since it uses the underlying Spotify Web API Python library.

[ 1.0.40 ] - 2024/07/02

  • Updated underlying spotifywebapiPython package requirement to version 1.0.73.
  • Updated SpotifyClient.GetSpotifyConnectDevices to gracefully handle device unavailable scenarios. It will try to reach the device by its direct HostIpAddress first; if that fails, then it will try to reach the device by its Server alias; if that fails, then it will log a warning that the device could not be reached and press on.
  • Updated ZeroconfConnect.Disconnect to check for an invalid JSON response. It has been found that some devices (Sonos, etc) do not return a proper JSON response for the resetUsers action. If a JSON response was not returned, then it will treat the http status code as the response code; if it’s not a 200, then it will raise an exception.
1 Like

I have an issue when trying to modify, pause or stop music whilst spotify is casting on my Sonos speaker

Failed to call service media_player/media_pause. Restricted device

If playing on my computer speaker all works fine.

Please advise?

@joolz1
Issues have been reported for some types of Sonos gear not being fully compatible with the SpotifyPlus integration.

The good news is that I am working with another forum member on trying to resolve Sonos issues. I am currently awaiting a Sonos device to arrive so that I can do some more in-depth testing and possibly find solutions to these issues.

In the mean-time, I created a new issue on the SpotifyPlus Issues page to track your specific issue. Please use the issues link above to track and report progress on your issue.

I installed the integration and used one of your sample YAML code (Browse Media Library) for a dashboard card with the mini-media-player and browser-mods, but I can’t figure out how to get them to cast to my Google Cast devices. I have a group of speakers and individual speakers. Can they be added if they’re on a different subnet?

@NRP1
Not for sure on the Google Cast, as I am a Bose Soundtouch guy. You may need to use Spotcast to wake them up for play.

Can you select any speakers from the Source selection list in mini media player? If they support Spotify Connect discovery then they should show up in the source list; just make sure you have the mini media player show_source: true option set so that the source list dropdown selection list is enabled.

@joolz1

FYI - just released a new version of the SpotifyPlus integration

[ 1.0.41 ] - 2024/07/18

  • Added support for Sonos device control and status updates via the Python SoCo (Sonos Controller) API package. These changes will allow you to control playback, obtain current status, and transfer Spotify Connect Player control to / from the device. Note that this works best when the device is controlled by the various Spotify Applications (e.g. Desktop, Mobile, and Web). Sonos devices that are controlled by the Sonos Applications can behave erratically when monitored by SpotifyPlus. More information on why that is can be found on the Spotify Connect Brand Notes wiki documentation page.
  • Updated underlying spotifywebapiPython package requirement to version 1.0.76.

This should give you the ability to transfer playback to another Spotify Connect device, including Sonos devices; use the Player Transfer Playback service, specifying the Spotify Connect device name to transfer to. Like so:

service: spotifyplus.player_transfer_playback
data:
  entity_id: media_player.spotifyplus_todd_l
  device_id: "Sonos-Office"

I also put together a Spotify Connect Brand Notes page that documents some of the quirks and oddities that I have ran into trying to control Sonos Spotify Connect devices.

Note that I only have a Sonos Symfonisk (gen 2) device to test with, so let me know if it works with any other Sonos device types. I would like to document the specific Sonos device types it does / does not work with.

Give it a try and let me know how it goes.

FYI - just released a new version of the SpotifyPlus integration

[ 1.0.42 ] - 2024/07/23

  • Added service player_set_repeat_mode that sets repeat mode for the specified Spotify Connect device.
  • Added service player_set_shuffle_mode that sets shuffle mode for the specified Spotify Connect device.
  • Added service player_set_volume_level that sets volume level for the specified Spotify Connect device.

These services allow you to set shuffle, repeat, and volume level for specific device id’s. I forgot to add these services to the list of integration custom services. I did not account for someone wanting to set shuffle / repeat / volume level on a specific device id. I assumed (incorrectly) that users would be calling the standard HA media player services, forgetting that they do not support the device_id functionality.

2 Likes

FYI - just released a new version of the SpotifyPlus integration

[ 1.0.43 ] - 2024/07/23

  • Updated service player_media_play_context to correctly default the position_ms and offset_position argument values. This was causing the playlist to always start at the first track if the offset_position argument value was not supplied. This manifested itself when shuffle was enabled, as the playlist should have started at a random track and was not doing so.
  • Updated service player_media_play_tracks to correctly default the position_ms argument value.

Also released a new SpotifyPlus BluePrint that will start a Spotify Context (playlist, album, artist) in shuffle mode.
More information can be found on the SpotifyPlus BluePrint wiki page.

2 Likes

With the new version I am getting this error when trying to initialise playing music from the integration, please advise?
I am unable to commence any music to Spotify speakers from the integration.

Failed to call service media_player/media_play. UPnP Error 701 received: Transition not available from 192.168.50.123

To play any music I am having to commence the playing from the Windows Spotify App, and then I can control with the integration providing I am only playing via computer speakers, as soon as I pair to Spotify speakers from the Windows app I get this error:

Failed to call service media_player/media_next_track. Restricted device

FYI - just released a new version of the SpotifyPlus integration.

[ 1.0.44 ] - 2024/07/24

  • Updated service player_set_shuffle_mode to correctly set shuffle mode for Sonos devices.
  • Updated service player_set_repeat_mode to correctly set repeat mode for Sonos devices.
  • Updated service player_set_volume_level to correctly set volume level for Sonos devices.

I updated from 1.0.40 to 1.0.44 and I can no longer use the Transfer Playback to initialize a timed out device. This is for a Phillips WiFi enabled smart speaker. When I revert back to 1.0.40 it works again.