SpotifyPlus Custom Integration

FYI, I posted an Enhancement request to the card owner of the generic Spotify card. I plugged in the SpotifyPlus integration media_player and of course it works, but looking at all the new functionality makes me want to sing!

Searching? I mean this is perfect.

You may wish to leave behind suggestions, the more there are helps to drive whether the change will happen.

1 Like

Thanks @kbrown01, appreciate it.

I can add more services as are needed, as the ones the integration supports are only about 30% of the underlying services available. Check out the spotifywebapiPython library to see if anything else catches your eye and let me know.

Hi!
I entered the wrong Spotify authentication information and despite uninstalling the integration it takes me to the same point, I cannot change this information. So I’m stuck setting up Spotify Plus.
An idea?

image

@stban1983 It sounds like you entered the wrong application credentials maybe?
If you have multiple Spotify accounts defined, ensure that the account you are logging on to Spotify with when installing the integration is the same account for the specified Spotify Application Client ID and Secret. If it’s not, then click on the “Not you?” link on the “Agree” form, and re-login to Spotify with the correct account.

I would suggest that you do the following:

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

Many thanks, it’s working!
I was missing this point:

1 Like

FYI - just released v1.0.8 of the SpotifyPlus integration:

  • Added service playlist_items_add to add one or more items to a user’s playlist. Items are added in the order they are listed in the uris argument.

This fulfills this Request made by user @ih8gates @OzStone @m4tthall73.

1 Like

Interesting. Can you talk about some of the interesting ways you use this, @thlucas?

I like, of course, the playlist_items_add that you added. I worked out my own kludgy version that talks to a PHP server since I understand PHP better than Python. But it’s kludgy for sure. But other than that, I’m not sure about how I’d use this.

@ih8gates The thought behind the playlist_items_add service is that you could easily click a button next to the media player to add the currently playing track to a “Liked Songs” playlist.

What HA really needs is a custom card (or even a built-in one) that can take advantage of the new service_response data features without having to use template sensors (16k limit). For example, I could build a card that populates “Made For You” Spotify playlist items, where the user clicks on one to play. Or create a card with Spotify Search functionality - a textbox to enter search criteria, a dropdown list to select the type of criteria (playlist, artist, album, etc), and a “Search” button to start the search. Display the results (from real-time service_response data) in a grid (with cover art) and clickable items to play content.

All kinds of stuff we could be doing with service_response data right now that no-one can take advantage of because it’s not fully supported yet.

To be clear I am not complaining - just hoping we can get that functionality soon.

Hope it helps.

I totally see the value of that playlist_items_add - I have a voice command / automation to “remember this song” when I’m listening to Discover Weekly, etc, and want to add it to a playlist.

I meant for your integration in general. What needs were met when you created this integration?

@ih8gates The reason I created the SpotifyPlus integration (or to be clear, cloned the built-in Spotify integration) was to add custom services to support my SoundTouchPlus integration. I was able to implement Spotify support into the Media Browser for SoundTouchPlus. It makes direct service calls to the SpotifyPlus integration to provide the media browser support.

I also didn’t like the responsiveness of the original Spotify integration, as it was slow to detect changes to the player state. My changes for player state improvement are not perfect either, but it’s the best I can do until Spotify releases a websocket API for real-time player updates (like Bose has for their SoundTouch products).

Hope that answers your question.

1 Like

Has anyone got any yaml examples on how to add this on a dashboard ?

The advanced features in your integration look promising, especially the music machine. :star_struck:

At the moment I’m using the official Spotify integration toghether with Spotcast. To you have a similar feature or do I still have to use Spotcast?

@j_d Spotcast requirement is determined by your speaker / receiver hardware. I do not need Spotcast to start playback on my Bose SoundTouch speakers. It should be able to start play on any device that is known to Spotify Connect, as it retrieves the device list from the Spotify Web API directly. I say “should be”, as I don’t have any other types of hardware besides my SoundTouch speakers to test with.

Other users have reported that Spotcast is required for playback on Google Chromecast devices. I have not had any feedback on Sonos or other types of hardware. I believe the Chromecast Spotcast requirement is needed because the speaker has gone into “sleep mode” and cannot be awakened to start play.

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