What I really appreciate about Spotify is the good connectivity. You can play or control music or podcasts on another device with just a few clicks.
Thanks to the free possibility of setting up developer access, many of these functions can also be accessed from NodeRed. With a few cleverly linked nodes, you can easily create your own “Spotify remote control” for (for example) the dashboard.
The control options are of course not limited to the dashboard. The control option could also be triggered, for example, via connected buttons or other options. 🙂
You can find a first approach to this in the following article.
Inhalte
- 1 Safety instructions
- 2 Affiliate links / advertising links
- 3 Requirements
- 4 Log in to the NodeRed configuration interface
- 5 Credits
- 6 Install the needed nodes
- 7 Activate the Spotify Developer account
- 8 Insert NodeCode
- 9 Enter account access data in NodeRed
- 10 Solution for error “INVALID_CLIENT: Invalid redirect URI”
- 11 The Spotify playback jumps or stalls sometimes
- 12 Have fun with the project
Safety instructions
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
Affiliate links / advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Requirements
Helpful Articles:
So that you can install new nodes, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.
- RaspberryPi – Setup for nerdiys!
- RaspberryPi – The first configuration!
- RaspberryPi – Control the RaspberryPi via SSH
- NodeRed – Installation of NodeRed on the RaspberryPi
- NodeRed – Installing new nodes
- NodeRed – Import and export node code
Required tools:
-none-
Required material:
In the following list you will find all the parts you need to implement this article.
Log in to the NodeRed configuration interface
Before you can edit your NodeRed configuration you must - if activated - first log in to the NodeRed configuration interface.

Credits
First of all, thanks to gelo2002 for his flow. The NodeCode offered below is based on its free shared code. I just added a few (useful in my opinion) extensions. The main work has been done by gelo2002. 🙂
You can find information about his flow here:
https://gist.github.com/gelo2002/1727790dfc3f6bac8c5b39f5a952b804
or here
https://flows.nodered.org/flow/1727790dfc3f6bac8c5b39f5a952b804
Install the needed nodes
So that NodeRed can communicate with your Spotify-Account you have to install the node
- node-red-contrib-spotify
How nodes are installed is described in the article NodeRed – Installing new nodes.
Activate the Spotify Developer account
So that you can control the various functions of your Spotify account, you must first set up a developer account for your Spotify account. This is free of chage and is done with a few clicks. 🙂

… and enter a name and a suitable description for it. You can choose both as you like, but of course they should be reasonably meaningful. 🙂

Then you will be redirected to the overview of this “app” (this is what Spotify calls the developer access). There you will find the “ClientID” and the “ClientSecret” on the left. You will need both laterso you should write them down somewhere.

After you have clicked on “Edit Settings” in the overview, you will be directed to the view shown. There you have to enter the appropriate “Redirect Uri”. This Redirect Uri depends on the address of your NodeRed server.
If this can be reached, for example, at the address https:// server.fritz.box, the Redirect Uri would be as follows:
- https:// server.fritz.box:1880/spotify-credentials/auth/callback
Make sure that you select the correct protocol (i.e. http or https).
Insert NodeCode
Now to the actual NodeCode. This includes the control of the simplest functions. So you can pause and continue playback, select the next or previous track, “scroll” in the song and get the album cover displayed.
As always, you can find the NodeCode in the following part in the Nerdiy Git repository under:


Enter account access data in NodeRed
After you have created a developer access to your Spotify and inserted the NodeCode, you can now switch to your NodeRed configuration. Click on one of the Spotify nodes there and start configuring a new access there.

Now you have to enter your ClientID in the text field next to “ClientID” and your client secret in the text field next to “Client secret”.
You can find both in the previous step in your Spotify Developer access.

Next you have to enter the desired “Scopes”. Scopes stand for the services that you want to control from NodeRed.
For this flow here you can enter the following scopes:
streaming user-follow-modify user-read-currently-playing user-modify-playback-state
You can find a complete list at: https://developer.spotify.com/documentation/general/guides/authorization/scopes/

This will open a new window in which you now have to confirm that you have allowed your NodeRed to access your Spotify account.
If you get an error message at this point, you can find a solution in the paragraph “Solution for error” INVALID_CLIENT: Invalid redirect URI “. 🙂

After you have confirmed this, you will be redirected to a website on which only the short message “spotify: authorized” is displayed.
Solution for error “INVALID_CLIENT: Invalid redirect URI”
The solution to the error reporting: INVALID_CLIENT: Invalid redirect URI I found here:
https://github.com/pckhib/node-red-contrib-spotify/issues/16
In principle, the error is caused by the fact that the “Redirect URI” was not configured correctly in the developer account. To get the correct Redirect URI, you can use the following trick.

Enter your URI in the URL decoder (https://www.urldecoder.org/) and let it decode.
The marked part in the lower field then corresponds to the Redirect URI, which you have to enter in your Spotify account.
The Spotify playback jumps or stalls sometimes
Every now and then it happens that the playback on one of my devices (no matter which one) jumps or stops. By trying it out, I found out that this seems to be related to the linking of the Spotify account with external services (for example the NodeCode presented here).
In retrospect, I explain it like this: Because Spotify wants to keep the playback data synchronized on all connected participants, I can imagine that a participant who answers too slowly could bring this synchronization out of sync.
Long story short: If you also observe this error: For me it helped to restart the computer on which NodeRed is running or, in the “worst case”, to unlink the Spotify account.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂
Hast du Playback Transfer auf ein anderes Gerät zum Laufen bekommen? In der vorletzten Version schickte man da einfach ganz stupide die Geräte ID samt Play Befehl auf die TransferMyPlayback API – nun tut sich da nix mehr.
Moin Steven,
habe ich tatsächlich noch nicht ausprobiert. Hast du mal die API von Spotify gecheckt ob es da Infos zu gibt?
Beste Grüße
Fabian
Hi Fab,
I was wondering how you select a playlist or song to begin with? I am a bit confused about this. It seems like you have somehow already configured the spotify node to get a playlist/song.
Hi Asad,
currently I use this only to display information of the current playing song. Selecting the song and co is done via the smartphone/desktop app of spotify. Nevertheless it is also possible to do this via the spotify node. 🙂
Best regards
Fab
Thank you for your response. I’m a bit confused as to how you would enable that. There doesn’t seem to be a specific way to do this. Do you have a tutorial that selects the song via the spotify node?
Thanks,
Asad
Hi Asad,
unfortunately not (yet). But I will put it on my list and will try to prepare something like this soon. 🙂
Best regards
Fab
Thanks for letting me know.