SpotifyPlus Integration

@Tim_Br are you talking about adding the media player itself to a dashboard?
If so, here is what I use via mini media player:

Mini Media Player Configuration:

type: entities
title: Mini Media Player - SpotifyPlus
entities:
  - type: custom:mini-media-player
    entity: media_player.spotifyplus_todd_l
    artwork: full-cover
    artwork_border: true
    power_color: true
    show_source: true
    group: false
    source: full
    info: long
    hide:
      power: true
      repeat: false
      runtime: false
      shuffle: false
      source: false
      volume: false

Standard Media Control Card Configuration:

type: media-control
entity: media_player.spotifyplus_todd_l

I don’t have any lovelace cards on the playlist_add_items service, but it would be a simple button definition with an item click action calling the following service (adds the currently playing track to the end of a playlist):

service: spotifyplus.playlist_items_add
data:
  entity_id: media_player.spotifyplus_playername
  playlist_id: 4yptcTKnXjCu3V92tVVafS

@Tim_Br I put together a quick example using Mini Media Player with a shortcut button to add the currently playing track to a playlist. I also added a new UI Dashboards page to the SpotifyPlus project wiki that documents these examples.

Check out the Add Track to Playlist example for what it looks like and the YAML configuration.

@Tim_Br @ih8gates @j_d
FYI - just released v1.0.9 of the SpotifyPlus integration :

  • Added service playlist_create to create a new Spotify playlist.
  • Added service playlist_change to change the details for an existing Spotify playlist.
  • Added service playlist_cover_image_add to replace the image displayed for a specified playlist ID.
  • Added service playlist_items_clear to remove (clear) all items from a user’s playlist.
  • Added service playlist_items_remove to remove one or more items from a user’s playlist.
  • Added service save_track_favorites to save one or more items to the current user’s track favorites.
  • Added service remove_track_favorites to remove one or more items from the current user’s track favorites.
  • Updated media_player.play_media method to better support play_media service enqueue features.

I also put together a quick example using Mini Media Player with a shortcut button to add / remove the currently playing track to the current user’s track favorites.
Check out the Add Track to Favorites example for what it looks like and the YAML configuration.

1 Like

FYI - just released v1.0.11 of the SpotifyPlus integration

  • Updated media_player SCAN_INTERVAL to 1 second to inform HA of Spotify status updates in near real time (e.g. pause, resume, next track, etc).
  • Updated media_player.update logic to only call the spotifywebapiPython SpotifyClient.GetPlayerNowPlaying every 30 seconds OR if a player command is issued (e.g. pause, play, next / previous track, seek, volume, etc) OR if the current track is nearing the end of play (e.g. next track in a playlist or queue).
  • This update adds a few more calls to the Spotify Web API, but not many. The trade-off is near real-time updates of player status.
  • Added service follow_playlist to add the current user as a follower of a playlist.
  • Added service unfollow_playlist to remove the current user as a follower of a playlist
  • Added service follow_users to add the current user as a follower of one or more users.
  • Added service unfollow_users to remove the current user as a follower of one or more users.

FYI - just released v1.0.12 of the SpotifyPlus integration

  • Updated underlying spotifywebapiPython package requirement to version 1.0.40.
  • Added service turn_on and turn_off support for the player. Playback control is transferred to the player after turning on. Configuration options support the execution of scripts to allow external devices to be powered on and off. Refer to the wiki documentation on how to configure this feature.
  • Added support for media controls to properly function when the Spotify Connect Player loses the active device reference. For example, when the player goes into an idle state due to player pausing for extended period of time, you can now resume play without having to re-select the source (avoids No active playback device found errors).
1 Like

@thlucas

I’ll try to answer your questions from our discussion in the Sonos Card thread:

Sonos is a Spotify Connect device, although I’m not sure the two companies are in complete sync with each others development.

I don’t use any scripts to power the device on because I don’t have to do so. Control everything for my Sonos devices from within the Sonos Card which allows access to anything offered by the Sonos device app and ecosystem. The Sonos Card uses the official Sono integration which exposes everything the Sonos can see, including Spotify (as long as the HA official Spotify integration is also installed. Everything is accessed through the HA media browser accessed from within Sonos Card.

I’m not using multiple Spotify accounts, just one premium paid account.

The error I’m receiving is still the same as you saw in the other thread. All of my play lists appear to have images, which were automatically assigned. The images are a single album cover, or a combination of 4 album covers depending upon what is in the playlist.

My Audio system consists of 4 Sonos devices as sources for a Russound 16 zone whole house amp system. I also still have a couple old Slim Devices/Logitech Squeezebox devices set up and sources for the Russound (which in some ways are still better than anything Sonos ever delivered).

I control the Russound zones with HA via individual media players or zone groups with scripts. Otherwise everything for the Sonos devices is controled within the Sonos Card.

I am able to use the Spotify app on my IOS devices to send playlists to the Sonos as a work around. Other wise I can get at any other Spotify Artist, album, or track through the Sonos Card via the media browser.

I hope some of all that helps you in some way and I will try to help further if I can. But I really don’t use Spotify Plus since it can’t play anything on my system except through my web browser. But I can at least browse Spotify playlists in it, so you are doing something right that the official Spotify integration isn’t…

@prgeno
Thanks for the info! I’m currently traveling for the Easter holiday, but will take a closer look on Monday.

At first glance, it seems like it might be better to approach the Sonos card developer (Phil?) about adding support for SpotifyPlus. He might not be open to that though.

I’ll know more on Monday.

@thlucas

That’s exactly what I did, we’ll see what his thoughts might be.

1 Like

I just installed and configured the integration, created just a card to test it, but everytime i try to play a song from my spotify i get an error about media_player.play media service telling me the media player created by this integration does not support this service. I have a free account…
Where am i wrong?

@maurizio53
Are you able to browse Spotify media via the HA Media Browser using the player? That will rule out an account configuration problem, versus a media player issue.

Are there any errors showing up in your system logs related to SpotifyPlus integration?

Yes, i can browse all the media of my spotify account, but cannot play anything.
EDIT: Nothing in the logs…

@maurizio53
How did you play Spotify content prior to SpotifyPlus?

If you are using the Sonos card, then it probably won’t work as Sonos Card only supports Spotify integration (no SoundTouchPlus support AFAIK).

Also, what type of hardware are you using for play: Sonos? Bose Soundtouch? Chrome cast?

Thanks for your patience - I need to understand your environment before I can offer suggestions on how to fix.

Before i was using spotcast integration and only on chromecasts devices as in sonos it was not working. I have many chromecast devices and some echo…
Hope you fix this as your integration has more interesting features.

@maurizio53
Regarding ChromeCast devices and SpotifyPlus, you will still need to utilize SpotCast to play to those devices. I have not tested SpotifyPlus with Sonos, as I do not have any Sonos devices (Bose SoundTouch guy).

I am trying to learn how existing Sonos users play content using the original Spotify integration - it seems that the few Sonos users I have encountered (@prgeno ) are using the Sonos card for that. I am not quite sure how the Sonos card works, so I will be taking a look at that in the next few days. Hopefully it’s something simple, or maybe the Sonos card developer(s) could add support for SpotifyPlus. I will keep you posted on that effort.

Ok, can you send me a code for example how to use spotcast with your integration? I still cannot use spotify with Sonos card so when you know how to do it, please let me know…

@maurizio53
I don’t have any SpotCast examples on how to use Spotify (nor SpotifyPlus) with Sonos gear. You might reach out to the Sonos Card developer @PunxsutawneyPhil to see if he has an example of playing Spotify on Sonos gear using the Sonos Card.

Ok, but i was meaning about the use of Spotcast with SpotifyPlus and not with Sonos, but with Chromecast devices…

@maurizio53
Sorry, I should have been more clear. The only examples that I have for configuring SpotifyPlus is for the Bose SoundTouch line of gear, which does not require SpotCast. I don’t have any SpotCast examples on how to use Spotify (nor SpotifyPlus) with Google ChromeCast gear.

Check out the SpotCast integration GitHub project for more information on how to configure SpotCast for Google Chrome devices.

@prgeno
I had a chance to install and play with the Sonos Card today. I was able to successfully use it as a music player with the SpotifyPlus integration, keeping in mind that I do not have any Sonos devices attached. See Figure 3 below for an example.

I had to set the showNonSonosPlayers: true value in order for the Spotify, SpotifyPlus and SoundTouchPlus media players to show in the UI (obviously).

Some oddities that I noticed when using it with my Bose SoundTouchPlus integration media player:

  • Volume Changes - are not consistent among different media player types. For example, the Spotify and SpotifyPlus integrations were receiving the standard media player service command of set_volume_level to change the volume level. The SoundTouchPlus integration never received a set_volume_level service request, even though the Sonos Card volume slider adjusted to the new position.

  • Pause / Resume Play
    A media_pause service command was received to pause the playing content, but after about 10 seconds the player would display No media selected if resume had not been selected. It would also not allow you to resume play if the resume button was clicked within 10 seconds. The player remained in a paused state as normal for the Spotify and SpotifyPlus integrations.

Some oddities that I noticed when using it with ANY non-Sonos (SoundTouchPlus, Spotify, SpotifyPlus) integration media player:

  • Media Browser Favorites - the Sonos Card keeps calling the
    async_browse_media method with a media content type of favorites. I believe this is to query Sonos specific favorites maybe? It does this for both my SpotifyPlus and SoundTouchPlus integration media players. I had to put defensive code into the integrations, as it was raising exceptions and adding a lot of entries to the system log since it calls it every 3-10 seconds (even with numberOfFavoritesToShow=0). There is no favorites equivalent for the Bose SoundTouch (it stores favorites on a per music service basis).

My next step is to add my findings to the SpotifyPlus wiki documentation, as I like the Sonos Card UI layout for playing Spotify content. It’s a really cool player interface!

There are too many issues to recommend it for use with the SoundTouchPlus integration though. This is not a bad thing, as the developer probably did not have any Bose SoundTouch devices to test with (just like I don’t have any Sonos devices to test with). It’s near impossible to develop an integration for technology that you do not have on hand, and expect it to work flawlessly.

Anyway, hope it helps!

Figure 1 - SpotifyPlus Media Library
Notice the “Made For You” node item for browsing the Spotify “Made For You” content (see Figure 1a below). It also allows you to customize each media library index node with a custom image if you like.

Figure 1a - SpotifyPlus Made For You Content

Figure 2 - Spotify Media Library

Figure 3 - Sonos Card YAML
The following is my Sonos Card test YAML definition, defined to a new dashboard with a view type of Panel (1 card).

type: horizontal-stack
title: Sonos Card Test
cards:
  - type: custom:sonos-card
    sections:
      - groups
      - volumes
      - grouping
    showNonSonosPlayers: true
    entities:
      - media_player.spotifyplus_todd_l
      - media_player.spotify_todd_l
      - media_player.bose_st10_1
    mediaBrowserItemsPerRow: 10
  - type: custom:sonos-card
    sections:
      - player
    showVolumeUpAndDownButtons: true
    showNonSonosPlayers: true
    showAudioInputFormat: true
    artworkAsBackground: true
  - type: custom:sonos-card
    sections:
      - media browser
    showNonSonosPlayers: true
    predefinedGroups:
      - name: Group 1 SpotifyPlus
        media: ''
        entities:
          - player: media_player.spotifyplus_todd_l
      - name: Group 2 Spotify
        media: ''
        entities:
          - player: media_player.spotify_todd_l
      - name: Group 3 Bose ST-10-1
        media: ''
        entities:
          - player: media_player.bose_st10_1
    topFavorites:
      - Top Favorites Custom Title
    mediaBrowserTitle: Media Browser Custom Title
    numberOfFavoritesToShow: 20
    entities:
      - media_player.spotifyplus_todd_l
      - media_player.spotify_todd_l
      - media_player.bose_st10_1

This integration is great and provides a lot of fun possibilities. I’m currently trying to automatically generate daily playlists with it.

Some services depend on the ‘playlist history id’ and I am not sure how to find this specific id. Can someone help me out?