SpotifyPlus Integration

@witno
It looks like you are trying to activate a ComoAudio Spotify Connect device.

It looks like your firewall settings are fine, as it is resolving the zeroconf parameters in the response and the zeroconf getInfo is returning information.

I would check the following:

  1. ensure you have the Spotify Connect Device LoginId, Spotify Connect Device Username, and Spotify Connect Device Password configuration options set in the SpotifyPlus Configuration Options.

  2. per the Como Audio User Manual (page 33): “Ensure the unit has the ‘Keep Network Connected’ option turned On. This will enable Spotify
    streaming to the unit when in Sleep or a non-network mode such as DAB/FM and Aux in.

  3. and per the same Como Audio manual: “A paid Spotify Premium account is required to use Spotify Connect.

#1 is key, as your device uses a tokenType = accesstoken, which requires the Spotify LoginId, Username, and Password. Check out the wiki docs, [Spotify Connect Device Username) for how to find these for your Spotify accounts.

@thlucas Thanks. I really appreciate you comprehensive reply. Wow!
I will try to fiddle around with the Spotify Connect Device LoginId 1, Spotify Connect Device Username, and Spotify Connect Device Password configuration options set in the SpotifyPlus Configuration Options.
The thing is that the Home Assistant site is actually an off-grid cabin (powered with solar panels, batteries, mobile broadband. LAN is a ubiquiti site network. I am not at the cabin now, but accessing it through VPN/TeamViewer. I Have several raspberrypi-divices and a WIN11 NUC that I can connect through.

1 Like

FYI - just released a new version of the SpotifyPlus integration

[ 1.0.63 ] - 2024/10/31

  • Updated underlying spotifywebapiPython package requirement to version 1.0.113.
2 Likes

Are you using voice to play specific music? I’m have a pipeline with OpenAI in HA Assist. Unfortunately I was not successful in playing specific artists or playlists using voice.
Thanks!

:sunglasses: Maybe helpful for others too. I just created one example automation on my own:
“Play music of {Artist}” as an example how SpotifyPlus can be used for Voice / Assist:

alias: Spiele Musik von <Artist>
description: ""
triggers:
  - trigger: conversation
    command:
      - Spiele Musik von {artist}
conditions: []
actions:
  - action: spotifyplus.search_artists
    metadata: {}
    data:
      entity_id: media_player.spotifyplus_lt12b
      criteria: "{{ trigger.slots.artist }}"
      limit: 3
    response_variable: resultspotify
  - action: media_player.play_media
    target:
      entity_id: media_player.spotifyplus_lt12b
    data:
      media_content_id: spotify:artist:{{ resultspotify['result']['items'][0]['id'] }}
      media_content_type: artist
mode: single

Is there a known library for custom media sentences?

1 Like

FYI - just released a new version of the SpotifyPlus integration

[ 1.0.64 ] - 2024/11/03

  • Added service add_player_queue_items to add one or more items to the end of the user’s current Spotify Player playback queue.
  • Added service get_artist_related_artists to get Spotify catalog information about artists similar to a given artist. Similarity is based on analysis of the Spotify community’s listening history.
  • Added service get_artist_top_tracks to get Spotify catalog information about an artist’s top tracks by country.
  • Added service get_audiobook to get Spotify catalog information for a single audiobook. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
  • Updated underlying spotifywebapiPython package requirement to version 1.0.114.
2 Likes

@thlucas thank you for creating this integration and Lovelace card. Have been looking for this type of solution since I first started using Home Assistant years ago. I installed successfully, but am trying to figure out the best way use in my ecosystem of Chromecast speakers and devices. I have historically started music playing on my phone and then used buttons in Lovelace that trigger scripts calling spotcast and sending music to the desired device(s). I am hoping to achieve similar functionality using the SpotifyPlus card as the mechanism to find and play music combined with buttons to trigger spotcast and send music to devices. However, I have not yet found a way to use the SpotifyPlus card to select and play music without first selecting a player. If I can start playing music in the SpotifyPlus, then I can use the spotcast buttons to send to speakers. Is there currently a way to use SpotifyPlus/Spotify Plus card to achieve this functionality?

@rml Unfortunately I have not had time to look at adding support for Chromecast devices as of yet. I don’t own any Chromecast hardware / devices, so it would be hard to develop something for it.

I just wanted to say a big thank you for this integration. I’ve been playing with the new ‘get song recommendations’ feature for a few days now and the possibilities it opens up are really cool.

I now get daily playlists perfectly tailored to different moods and I’m really enjoying that, so thanks for the time and effort you put into this project.

1 Like

Hi,

Firstly, I would like to thank you for all the time and effort that has gone into this integration, it really is fantastic. It is working pretty well for me.

I have one question but feel a bit stupid for asking, as I am sure I am missing something obvious. I am using a simple automation to start a playlist on a sonos device using spotifyplus.player_media_play_context. This seems to work well but if I open up any other spotify client e.g. web app, windows client, it doesn’t show as anything is playing. I thought it might be a timing thing, perhaps needing to sync after a while but still nothing shows in those clients after a longer period of time. Is this expected behaviour?

Also, and perhaps another simple question to answer, how can I ensure when the playlist starts it does so in shuffle mode rather than playing in the same order each time?

Thanks again!

@m4tthall73
Hi Matt - thanks for reaching out, and there is no such thing as a stupid question. :smiley:

The following is taken from my Sonos Brand Notes wiki page, which explains what is happening …

  • Sonos devices do not support the Spotify Web API Start/Resume Playback endpoint from commercial streaming applications. A 403 Forbidden, Restricted device error is generated by the Spotify Web API if Start/Resume Playback is issued to a Sonos device. Note that Spotify applications do not have this limitation (e.g. Desktop / Mobile applications) and can play tracks or contexts at will, as they are not considered “commercial” applications. The SpotifyPlus integration player_media_play_context and player_media_play_tracks custom services get around this limitation by building a local queue on the Sonos device and issuing a SoCo Play command to play the local queue. Note that Sonos playback control is transferred from the SPOTIFY_CONNECT music source to the Sonos device local queue when this happens; the Spotify Connect source is paused after control is transferred to the Sonos local queue. The only way for Spotify Connect to regain control on the Sonos Device is via a Spotify Desktop / Mobile application.

As for the shuffle, I put together a blueprint to do this; or if you’re not into blueprints, use the following script (just change the entity_id , media_content_id , and device_id values):

alias: Spotify Playlist with Shuffle On
sequence:
  - service: spotifyplus.player_set_shuffle_mode
    data:
      entity_id: media_player.spotifyplus_todd_l
      device_id: Bose-ST10-1
      state: true
  - service: spotifyplus.player_media_play_context
    data:
      entity_id: media_player.spotifyplus_todd_l
      device_id: Bose-ST10-1
      context_uri: spotify:playlist:6M8n0Sp9895BXEE0MbGPde
mode: single
icon: mdi:music
1 Like

Thanks for the detailed reply and apologies, I should have picked up the answer to my first question in your wiki. I guess it isn’t a big problem so long as I solely use one or the other.

While I have your attention, I hope you don’t mind me asking one final question. I have been using the mini media player card in the dashboard but cannot see an automatic way for this to show whether the currently playing track is a favourite.

I guess I can add something separately using the following which I took from your wiki. Feels like an obvious thing lots of people would want so before going off and doing something custom, are you aware of anyone else doing this?

service: spotifyplus.check_track_favorites
data:
  entity_id: media_player.spotifyplus_john_s

@m4tthall73
I use mini media player myself, and it does not have this capability unfortunately.

With that said, I have recently created a SpotifyPlus Card dashboard that might be what you are looking for. I released it in a “beta” status a few weeks ago, and have shaken out most of the bugs. You are welcome to give it a try if you like; there is more information on the wiki; have a look at the Player Section details, as well as other Card Features. Installation is done via HACS, using the Installation Instructions defined on the wiki.

If you are still set on using the Mini Media Player, have a look at the SpotifyPlus UI Dashboards wiki doc; it contains a section on how to setup a couple of buttons in the Mini Media Player to add / remove favorites; unfortunately there is no way to display the favorite status without calling the check_track_favorites (like you mentioned in your comment) and implementing some sort of custom button interface to display the result. You might also have a look at the SpotifyPlus UI Scripts wiki, which shows you how to call a service from a script / automation and parse the results.

Sorry for the information overload - hope it helps!

1 Like

Just installed and had a play with you card and have to say, it’s fantastic, great stuff. However, unless I am missing something, while I can see if the track is a favourite by clicking on the info, I can’t configure this to show on the player. Is that right? If so, is there a way to have this as a config option?

The reason I ask is that I have a tablet with the dashboard on it and it is often playing music while I am in the kitchen cooking for instance. If it plays a track I would like to add to my favourites, I use a voice assistant (Google Nest unfortunately in this instance) to say “add favourite” and have this to use your integration to add the currently playing track to my favourites. While it isn’t particularly important, it would be nice if I could glance up and the dashboard and see if it is already in my favourites before making that command. Hope that makes sense.

Thanks once more!

1 Like

@m4tthall73
Yes, that makes perfect sense. I could probably enhance the card to display the current track favorite status. The information is already there, it’s just hidden in the information popup. I will look into it.

1 Like

Wonderful, thanks

@thlucas I’m speachless!
I’m trying to improve the control of my soundsystem and multiroom from ages, and your work seems amazing. Maybe I’ll say goodbye to Spotcast.
I want also to try to add a media browser popup to my dashboard, I could bother you :slight_smile: if (when) I’ll need help.

Thank you!

1 Like

@thlucas The SpotifyPlus Card is awsomme. Just what I have been looking for. Thanks!!
After sorting som issues with credentials for the Spotify Connect device in the Sportify Plus integration, I have started playing with the new card.
One thing that is not working on my end is to start playing when tapping og clicking the items in Playlists, Fovorites, etc. Long press endables the right More info. It just don’t shift over to the playlist/track/album, etc. I’m clicking.
Any suggestions.

@witno i would make sure that the latest SpotifyPlus integration version is installed, and the latest SpotifyPlus Card version is installed.

The Card is still in beta test mode, so it could be a bug. If you can open an issue on the wiki for this that would be great, so I can track it. Try to list the exact steps that you took before the issue occurs - screen captures are helpful, as well as the track / playlist your are trying to play.

Sorry. It’s prabably not the card. Been playing with it on a laptop with touch-screen. I can’t get the tracks/playlist’s etc. to start when tapping the touchpad, however when tapping the screen it started. Tried it on a desktop. No issue on the with using the mouse on that device.

1 Like