Spotify: Reorder Playlist (shuffle) (Bonus: Utilize the Get Methode)

Hi All,

Like the integration of spotify. My struggle, i create a alarm clock with raspotify which works like a charm.

Only bit i am missing in homeassistant is a that i can’t start a playlist without have to hear the first song in the playlist over and over. The second song will be diffrent because with setting the feature shuffle: true .

As it seems there is no solution for it provided by spotify (directly) i found a option withing the API which is a great way to satisfy my needs. I now have this running and tested in an with the Spotify API and it works. But of course i like to add it to my HA Script/Automation. Hopefully this is a small effort for you to add in.

Below you find the link to the feature page from spotify.

https://developer.spotify.com/console/put-playlist-tracks/

Challenges which might be faced:
you have to set the playlist item number before it must do the shuffle. This is different per playlist, i suggest to leave it to the user to give it in as an required parameter.

Request Body example:

{
“range_start”: 0,
“insert_before”: 20
}

As a bonus this could be be solved if there also was a way to use the GET methodes of Spotify. For example if before doing the Reorder, the script could do a GET Playlist you would know the total length of the playlist. This then can be used as the insert_before parameter for doing the Reorder.

Also as a extra bonus I would be happy if for example i could do a Get Playlists so i can make a input pull down menu where i can get the playlist id (URI) and then use it in an script/automation as the playlist it must start when triggered . Then again this is bonus, would be happy if i can stop my cronjob and would not have to maintain 2 platforms.

Thanks and also if i could help let me know, pretty well know how the Spotify API works.
Showing it off here :stuck_out_tongue: