Using Spotify through Node Red

for the moment same problem impossible for me to play and send playlist… could you share your flow please?

I have it working, but one thing I found (maybe it has bin mentioned) is that you have to have an active connection to the chromecast or speaker, for instance through a phone or pc, only the you can use it, the player goes idl ones not connected and it will not work

do you have a flow to share?

For Chromecast there are still some issues with invoking spotify from a non android device. Check the Spotcast custom component for a workaround.

it works with spotcast :slight_smile:

but i want to use it without home assistant :slight_smile:

Hi- @sender what do you mean by remove the oauth? From where and how, I’m facing the same issues. Would appreciate the help of you could outline the steps. Thanks!

I have done as you described but I get the error

{"_msgid":"fcbdb5bb.ed3928","topic":"","params":[{"deviceIds":["77c3c0a12cf8ef9ddca2dae79bdee811cc446f8d"],"play":"true"}],"err":"TypeError: Cannot read property 'play' of undefined"}

This is the code of my function node

msg.params = [ {deviceIds: ["77c3c0a12cf8ef9ddca2dae79bdee811cc446f8d"], play: 'true'} ]; return msg;

Any suggestions?

1 Like

Found the wright way to write the code for the the code of the function node here.

Now my code looks like:

msg.params = [
    ['2006d991d90ff991fb772ccc649f8dfcf316ac51'], /* DeviceIds Array (but it can only handle one device id) */
    { play: true } /* Options Object */
];
return msg;

Node red flow

[{"id":"9fcff8a1.e11c18","type":"debug","z":"1ec70ae1.ce8cc5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":890,"y":460,"wires":[]},{"id":"6e3b8927.c4256","type":"spotify","z":"1ec70ae1.ce8cc5","name":"","auth":"daae9818.5d9dc8","api":"transferMyPlayback","x":720,"y":460,"wires":[["9fcff8a1.e11c18"]]},{"id":"c3fde82d.b7bc38","type":"function","z":"1ec70ae1.ce8cc5","name":"Naar woonlamer","func":"\n\nmsg.params = [\n    ['2006d991d90ff991fb772ccc649f8dfcf316ac51'], /* DeviceIds Array (but it can only handle one device id) */\n    { play: true } /* Options Object */\n];\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":460,"wires":[["6e3b8927.c4256"]]},{"id":"45085da9.3094f4","type":"inject","z":"1ec70ae1.ce8cc5","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":320,"y":460,"wires":[["c3fde82d.b7bc38"]]},{"id":"daae9818.5d9dc8","type":"spotify-auth","name":"Spotify Sander","scope":"user-read-playback-position\nuser-read-playback-state\nuser-modify-playback-state\nuser-read-currently-playing\napp-remote-control\nstreaming"}]

Maybe this will help someone.

2 Likes

I also struggled to get Spotify authorized in Node Red. After following all steps I got a ‘401: Unauthorized’ message.

This seems to be the solution: When you see ‘401: Unauthorized’, select the URL in your address bar and hit Enter. Then you should see a ‘spotify.authorized’ message. Refresh won’t work.

I hope this helps other people. It took me some time to find this solution.

4 Likes

I’ve edited this because it used to work with a different format with state:“true”,but now it just wants “true”.

You can also just use an inject node with a msg.params = JSON

[ “true” ]

Rather than using an inject node of true, and then a function node with the parameters.

https://i.imgur.com/61aT6DB.png

2021-01-09

I also have that problem in Spotify authorization. do you have already a solution?

I had to use this in my inject node

image

So my function node in my flow for setting shuffle looks like this
image

I had the same I had to replace the https:// in to http:// in the url

Mine seems to work with both [ “true” ] and [ true ]

I’m looking for a way to “search” music.
I have already tried some variants, but unfortunately did not bring any success.
At the moment I’m trying to solve this with an “input_text”. But I also don’t know if this is the right way?!?

Interesting in getting this working to search for a song and play it. Unfortunately, I’ve no idea where to start. I’ve authenticated and I can play and pause on a selected device but that’s about it

hey,
I have a few questions about Spotify…
is it possible for me to tell Spotify to play a specific playlist through a flow?
I just can’t find the right node

Force reload the page by clicking the URL and hit “enter”. This helped me several times

Click the URL and hit enter in your browser. This solved this issue several times for me

Hello. I’m testing this spotify on my nodered but I’ve a little problem.
I’m able to send my playlist id and then play with shuffle, but if I try to choose as device my iphone, it don’t work.
It works only and only if I already have Spotify open on my iphone. Is there no way to make it always work?