I often listen to Spotify-generated playlist. Discover Weekly, Daily Mix, Release Radar, etc. Often, I’ll hear a song that I want to earmark to listen to later or add to a playlist. Here’s a method to do that.
While I keep my fingers crossed for an add_to_playlist service for the Spotify component, I’ve used IFTTT as the glue to make this work.
So, you’ll need to set up the IFTTT component so that you can trigger events. Follow the instructions on the component page.
On the IFTTT site, create a new applet. Select “Webhooks >> Receive a web request” for your “this”. Enter “add_to_playlist” as your event name.
Choose “Spotify >> Add track to a playlist” for your “that”. Choose a playlist name. I use “Remember”. Enter “Value1” for the search query and “Value2” for “Artist name.”
In my setup, I use the Universal Media Player component to keep track of what music is playing. This way, it doesn’t matter if I’m listening to Spotify or SqueezePlay or any supported media player. Since the IFTTT applet uses title/artist to search, you can “remember” songs from any media player and save it to Spotify.
Now, create a script that looks like this:
add_to_playlist:
alias: Add Spotify Track to Playlist
sequence:
- service: ifttt.trigger
data_template:
event: "add_to_playlist"
value1: "{{ states.media_player.mandark.attributes.media_title }}"
value2: "{{ states.media_player.mandark.attributes.media_artist }}"
Replace “media_player.mandark” (my universal media player) with “media_player.spotify”, etc, based on the media_player you’re using. Then set up an automation to call the script from a zwave remote or whatever. If you’d like to use this as Alexa intent, you can call the script from there:
RememberSongIntent:
action:
- service: script.add_to_playlist
speech:
type: plain
text: "Remembering {{ states.media_player.mandark.attributes.media_title }} by {{ states.media_player.mandark.attributes.media_artist }}"