Spotify Lovelace Card

this solve the problem, thanks :+1:

Hello everyone,

Its possible to hide this area?
image

Thanks

Off course:

    type: custom:spotify-card
    card_mod:
      style: |
        #footer {
          display: none !important;
        }
    hide_warning: false
    hide_top_header: true
    hide_currently_playing: true
    hide_playback_controls: true
    hide_chromecast_devices: false
    hide_connect_devices: true
    display_style: grid
    limit: 8
    grid_covers_per_row: 4
    playlist_type: discover-weekly
    always_play_random_song: true
1 Like

Thanks. for the solution

Hey, I’m using the card for quite some time now. I really love and use it a lot.
My only frustration is that my own playlist don’t show up in lovelace (those created by spotify, like "Release Radar, Discover Weekly, …) are displayed correctly however.

Does anyone have a solution for this?

Thanks,
J

 type: custom:spotify-card
hide: null
limit: 10
always_play_random_song: true
include_playlists:
  - .*Spot
  - .*ELE
  - .*Juh
  - .*Disco
  - .*Your
  - .*Rel
hide_connect_devices: true
spotify_entity: media_player.spotify_117408964
filter_devices: null
playlist_type: default
account: default
grid_show_title: true
grid_covers_per_row: '5'
display_style: list
1 Like

Good point. I hadn’t noticed but I’m seeing this same behavior. It seems like anything created by Spotify is not included in the list. That includes public playlists created by Spotify, and also the themed ones that say “… picked just for you”.

I was also having the problem others mentioned where the playlists won’t load at all. I was curious why just re-creating the card would fix it, so I pulled apart my definition one line at a time until it worked. What I found is that if I have a "limit: " value greater than 18 it will fail to load (not sure if that’s a fixed limit or something related to the number of playlists I have available in my account).

I installed this today.

I cant get it to work, it just says "error the spotify integration must be installed for this component to work… but it is installed and works with all other things

anyone got any tips for me

thanks

I got this installed, but I don’t like the device selection, it does not work good on touch or mouse input.
Is it possible to replicate the behaviour, I can hide the selection with CSS. But is it possible to create separate buttons for each device in my network?
Where I can select a device with the button I created and then press a playlist to launch it?
Or is this not possible?

Workaround:

1 Like

Restating:

Awesome card. Now able to make a room level card. There is a bit of a delay when the album graphics load. Is there a way to speed this up such as cache or something similar? No way a deal breaker, but very noticeable delay. Maybe there are some best practice performance tweaks ? Thanks

1 Like

What do you use as the underlying integration to Spotify?
I switched from the regular Spotify integration to the SpotifyPlus integration and the display of album art in the card went from 3 - 5+ seconds to almost instant.

The SpotifyPlus integration uses the spotifywebapiPython package - I wrote it as well. It makes calls directly to the Spotify Web API.

I believe the HA Spotify integration uses the spotipy python package, but not sure - it’s been awhile since I looked at it.

I have also started a beta test of my new SpotifyPlus Card UI, if you’re interested. It requires the SpotifyPlus integration. Check out the link for more info.

1 Like

I’ve been trying to integrate Spotify into my dashboard for a few weeks now. My idea is to have a few buttons that create and play playlists by mood. It works quite well so far and looks like this:

But the playlist creation service works very unreliably for me (other Spotify Plus integration) - or crashes my server. I have seen that this integration can also create playlists, but without songs. Can I also use the services to create a dynamic playlist with a few parameters such as “energy” and create some kind of jukebox with it? I’m a bit confused by the many options.

Also if someone needs the yaml for that Spotify playlist card just ask, i think the layout works quite well for a playlist selection card.

1 Like

with SpotifyPlus, you can create an empty playlist:

service: spotifyplus.playlist_create
data:
  entity_id: media_player.spotifyplus_john_s
  name: My New Playlist
  description: A Playlist created by the SpotifyPlus integration
  public: false
  collaborative: false

You would then need to add items to the playlist - there is no way to “auto populate” the playlist with a genre / vibe / popularity / etc. Here’s how to add items:

service: spotifyplus.playlist_items_add
data:
  entity_id: media_player.spotifyplus_john_s
  playlist_id: 4yptcTKnXjCu3V92tVVafS  <- the ID from the playlist_create call
  uris: spotify:track:0NL83oUQmHLErXLOuvhgNX

Note that the uris parameter can specify up to 100 track uri values (comma separated).

There is an API call available in the spotifywebapiPython (would need to be added to SpotifyPlus service list) that can be used to get track information based on genre (among other things) called GetTrackRecommendations.

One could (in theory) call the GetTrackRecommendations to return the list of tracks based on a genre / popularity / energy level, etc), create a dynamic playlist, and the add the found tracks to the playlist.

Here’s a Python example (from the help docs link above) that retrieves tracks with a genres of rock,hard-rock,rock-n-roll, minLoudness=-9.201, minTimeSignature=4, and minEnergy=0.975

from spotifywebapipython import *
from spotifywebapipython.models import *

try:

    CLIENT_ID:str = 'your_client_id'
    CLIENT_SECRET:str = 'your_client_secret'

    # create new spotify client instance.
    spotify:SpotifyClient = SpotifyClient()

    # generate a spotify client credentials access token (no scope, public data use only).
    spotify.SetAuthTokenClientCredentials(CLIENT_ID, CLIENT_SECRET)
    print('\nAuth Token:\n Type="%s"\n Scope="%s"' % (spotify.AuthToken.AuthorizationType, str(spotify.AuthToken.Scope)))
    print('\nUser:\n DisplayName="%s"\n EMail="%s"' % (spotify.UserProfile.DisplayName, spotify.UserProfile.EMail))

    # get Spotify track recommendations for specified criteria.
    print('\nGetting track recommendations - I wanna rock!\n')
    recommendations:TrackRecommendations = spotify.GetTrackRecommendations(seedGenres='rock,hard-rock,rock-n-roll',minLoudness=-9.201,minTimeSignature=4,minEnergy=0.975)

    print(str(recommendations))
    print('')

    seed:RecommendationSeed
    for seed in recommendations.Seeds:

        print(str(seed))
        print('')

    print('Recommended Tracks:')
    track:Track
    for track in recommendations.Tracks:

        print('- "{name}" ({uri})'.format(name=track.Name, uri=track.Uri))
        #print(str(track))

except Exception as ex:

    print("** Exception: %s" % str(ex))

Alright, nice. This sounds like it could theoretically work with a combination of a few service calls. Thank you very much for taking the time to write this up.

1 Like

@shpongledsummer
I am in the process of adding the get_track_recommendations to the SpotifyPlus integration. Will keep you posted.

1 Like

@shpongledsummer
I implemented the get_track_recommendations service with SpotifyPlus integration v1.0.62 …

[ 1.0.62 ] - 2024/10/27

  • Added service get_track_recommendations to get track recommendations for specified criteria.
  • Added the following extra state attribute: sp_track_is_explicit - denotes the nowplaying track contains explicit lyrics (true) or not (false).

SpotifyPlus Service Documentation is on the wiki. The service supports all of the parameters implemented by the Spotify Web API Get Track Recommendations endpoint.

Here’s a couple of service call examples:

Example YAML

I wanna rock! example …

service: spotifyplus.get_track_recommendations
data:
  entity_id: media_player.spotifyplus_john_s
  limit_total: 50
  seed_genres: "rock,hard-rock,rock-n-roll"
  min_loudness: -9.201
  min_time_signature: 4
  min_energy: 0.975

I wanna wind down example - artist George Winston (e.g. 3jdODvx7rIdq0UGU7BOVR3) …

service: spotifyplus.get_track_recommendations
data:
  entity_id: media_player.spotifyplus_john_s
  limit_total: 50
  seed_artists: "3jdODvx7rIdq0UGU7BOVR3"
  seed_genres: "piano"
  min_energy: 0.175
2 Likes

really cool, thanks for adding this!

1 Like

@shpongledsummer
I finally released the SpotifyPlus Card Dashboard that contains a feature you might like relating to the Track Recommendations that we discussed a couple of weeks ago.

The dashboard allows you to define a user-preset that contains recommendation criteria used to search Spotify for matching tracks. It then calls the GetTrackRecommendations endpoint to get the matching tracks, builds a play queue of the tracks, and starts playing.

The configuration supports all of the 45 different criteria for the get_track_recommendations service.

Feel free to check it out when you get some time. Here are some example screenshots and yaml configurations for presets that I have played with so far.

SpotifyPlus Card Configuration - userPresets

userPresets:
  - name: I Wanna Rock!
    subtitle: Recommended
    image_url: https://t.scdn.co/images/728ed47fc1674feb95f7ac20236eb6d7.jpeg
    type: recommendations
    recommendations:
      seed_genres: rock,hard-rock,rock-n-roll
      min_loudness: -9.201
      min_time_signature: 4
      min_energy: 0.975
  - name: Wind Down Piano
    subtitle: Recommended
    image_url: https://t.scdn.co/images/728ed47fc1674feb95f7ac20236eb6d7.jpeg
    type: recommendations
    recommendations:
      seed_artists: 3jdODvx7rIdq0UGU7BOVR3
      seed_genres: piano
      min_energy: 0.175
  - name: Wind Down Guitar
    subtitle: Recommended
    image_url: https://t.scdn.co/images/728ed47fc1674feb95f7ac20236eb6d7.jpeg
    type: recommendations
    recommendations:
      seed_artists: 3jdODvx7rIdq0UGU7BOVR3
      seed_genres: guitar
      max_acousticness: 0.15
      max_energy: 0.175
  - name: Wind Down Country
    subtitle: Recommended
    image_url: https://t.scdn.co/images/728ed47fc1674feb95f7ac20236eb6d7.jpeg
    type: recommendations
    recommendations:
      seed_genres: country
      max_speechiness: 0.225
      max_energy: 0.325

SpotifyPlus Card User Preset Browser

Generated Play Queue for the “I Wanna Rock!” preset

1 Like

oh wow, this sounds great! I guess I have something to tinker with this weekend :slight_smile: