spotify dashboad player/controller

This is my first flow published, feel free to comment on it.

Due to some limitations at my current workplace, it is possible to listen to Spotify only on my phone. More over, it has to be hidden, so an easy access to it, to change the song or see what is actually playing, is difficult.

On other hand I can have any website open on my work PC, o I created a flow, which uses:

  • "node-red-contrib-spotify"
  • "node-red-dashboard"

and what this does? It connects to my Spotify account and controls my Spotify App on the phone.

Features:

  • Previous/Next
  • Play/Pause
  • Current song (Title)
  • Album's picture
  • Seek bar with song's duration, current seek moment
  • MQTT status/control is also available

For Spotify agent configuration please see the description from the node.

[{"id":"bd80cf37.f9982","type":"tab","label":"Spotify","disabled":false,"info":""},{"id":"c2c469db.580898","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"getMyCurrentPlayingTrack","x":380,"y":60,"wires":[["2618401a.d4a3","d89db731.9dcb28","158b6d57.3b4133","64962fb7.11d53","ec129954.d01af8","7bc62009.3278a","4240c7f2.ebbae8"]]},{"id":"e821612e.e3cf4","type":"inject","z":"bd80cf37.f9982","name":"1s/1s","topic":"","payload":"true","payloadType":"bool","repeat":"1","crontab":"","once":false,"onceDelay":"1","x":130,"y":60,"wires":[["c2c469db.580898"]]},{"id":"2618401a.d4a3","type":"debug","z":"bd80cf37.f9982","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":670,"y":40,"wires":[]},{"id":"663ee350.a90bfc","type":"mqtt out","z":"bd80cf37.f9982","name":"","topic":"spotify","qos":"","retain":"","broker":"[YOUR CONFIG]","x":850,"y":80,"wires":[]},{"id":"d89db731.9dcb28","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.item.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":80,"wires":[["663ee350.a90bfc"]]},{"id":"158b6d57.3b4133","type":"ui_text","z":"bd80cf37.f9982","group":"4c99ccf8.ce4ef4","order":4,"width":0,"height":0,"name":"","label":"Track","format":"{{msg.payload.item.name}}","layout":"col-center","x":650,"y":120,"wires":[]},{"id":"5edcb928.352ed8","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"skipToNext","x":330,"y":180,"wires":[[]]},{"id":"41887616.7d8738","type":"ui_button","z":"bd80cf37.f9982","name":"","group":"4c99ccf8.ce4ef4","order":1,"width":"4","height":"1","passthru":false,"label":"Previous","tooltip":"","color":"","bgcolor":"","icon":"skip_previous","payload":"true","payloadType":"bool","topic":"","x":120,"y":260,"wires":[["346d2e57.3f7082"]]},{"id":"346d2e57.3f7082","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"skipToPrevious","x":340,"y":220,"wires":[[]]},{"id":"c15e8169.b6692","type":"ui_button","z":"bd80cf37.f9982","name":"","group":"4c99ccf8.ce4ef4","order":3,"width":"4","height":"1","passthru":false,"label":"Next","tooltip":"","color":"","bgcolor":"","icon":"skip_next","payload":"true","payloadType":"bool","topic":"","x":130,"y":140,"wires":[["5edcb928.352ed8"]]},{"id":"7a73ed1f.05fd24","type":"mqtt in","z":"bd80cf37.f9982","name":"","topic":"spotify.next","qos":"2","datatype":"auto","broker":"[YOUR CONFIG]","x":120,"y":100,"wires":[["5edcb928.352ed8"]]},{"id":"c5dea8fe.215358","type":"mqtt in","z":"bd80cf37.f9982","name":"","topic":"spotify.prev","qos":"2","datatype":"auto","broker":"[YOUR CONFIG]","x":120,"y":300,"wires":[["346d2e57.3f7082"]]},{"id":"64962fb7.11d53","type":"ui_template","z":"bd80cf37.f9982","group":"4c99ccf8.ce4ef4","name":"Album Pic","order":5,"width":"12","height":"6","format":"<div height=\"{{msg.payload.item.album.images[1].height}}\" align=\"center\">\n<IMG ng-src=\"{{msg.payload.item.album.images[1].url}}\"></IMG>\n</div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":660,"y":160,"wires":[[]]},{"id":"22da8308.01cf5c","type":"ui_switch","z":"bd80cf37.f9982","name":"Paly/Pause","label":"","tooltip":"","group":"4c99ccf8.ce4ef4","order":2,"width":"4","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"play_circle_outline","oncolor":"green","offvalue":"false","offvalueType":"bool","officon":"pause_circle_outline","offcolor":"red","x":670,"y":280,"wires":[["1774f4d0.a4739b"]]},{"id":"ec129954.d01af8","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"move","p":"payload.is_playing","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":220,"wires":[["22da8308.01cf5c"]]},{"id":"54f46f35.233","type":"switch","z":"bd80cf37.f9982","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":380,"wires":[["e497a2b8.fd79d"],["943e9a49.25e0f8"]]},{"id":"e497a2b8.fd79d","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"play","x":810,"y":360,"wires":[[]]},{"id":"943e9a49.25e0f8","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"pause","x":810,"y":400,"wires":[[]]},{"id":"1774f4d0.a4739b","type":"rbe","z":"bd80cf37.f9982","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":810,"y":280,"wires":[["54f46f35.233"]]},{"id":"79a3657f.878c5c","type":"inject","z":"bd80cf37.f9982","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":650,"y":420,"wires":[["943e9a49.25e0f8"]]},{"id":"c1699696.1dc128","type":"inject","z":"bd80cf37.f9982","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":650,"y":340,"wires":[["e497a2b8.fd79d"]]},{"id":"a22e150b.756278","type":"inject","z":"bd80cf37.f9982","name":"Next","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":180,"wires":[["5edcb928.352ed8"]]},{"id":"86b64b52.ec27b8","type":"inject","z":"bd80cf37.f9982","name":"Prev","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":220,"wires":[["346d2e57.3f7082"]]},{"id":"5e6aa81e.236958","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"getTrack","x":520,"y":580,"wires":[["6832171f.b21738","401fa237.e6689c","edd7f8d.22b6f08"]]},{"id":"6832171f.b21738","type":"debug","z":"bd80cf37.f9982","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":540,"wires":[]},{"id":"df71ed65.9b56d","type":"rbe","z":"bd80cf37.f9982","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":530,"y":480,"wires":[["2ce1a0e9.0f532"]]},{"id":"478a3775.62ec48","type":"debug","z":"bd80cf37.f9982","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":730,"y":480,"wires":[]},{"id":"401fa237.e6689c","type":"debug","z":"bd80cf37.f9982","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"params","targetType":"msg","x":750,"y":580,"wires":[]},{"id":"2ce1a0e9.0f532","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"params","pt":"msg","to":"[payload]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":580,"wires":[["5e6aa81e.236958"]]},{"id":"7bc62009.3278a","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"move","p":"payload.progress_ms","pt":"msg","to":"progress","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":640,"wires":[["3b445fef.e2239","c330a77b.500f58"]]},{"id":"edd7f8d.22b6f08","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"move","p":"payload.duration_ms","pt":"msg","to":"duration","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":680,"wires":[["fa925eeb.d8ada","c330a77b.500f58"]]},{"id":"332f05a0.74111a","type":"ui_numeric","z":"bd80cf37.f9982","d":true,"name":"","label":"progress","tooltip":"","group":"4c99ccf8.ce4ef4","order":6,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"100","step":1,"x":780,"y":640,"wires":[[]]},{"id":"3b445fef.e2239","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"progress/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":640,"wires":[["332f05a0.74111a","f1ffcbe7.256788"]],"outputLabels":["seconds"]},{"id":"fa925eeb.d8ada","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"duration/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":680,"wires":[["3c13b288.116c7e","19eb810.cf58c7f"]],"outputLabels":["seconds"]},{"id":"3c13b288.116c7e","type":"ui_numeric","z":"bd80cf37.f9982","d":true,"name":"","label":"duration","tooltip":"","group":"4c99ccf8.ce4ef4","order":7,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"100","step":1,"x":780,"y":680,"wires":[[]]},{"id":"511f99e0.c089b8","type":"ui_slider","z":"bd80cf37.f9982","name":"","label":"","tooltip":"","group":"4c99ccf8.ce4ef4","order":9,"width":"8","height":"1","passthru":true,"outs":"end","topic":"","min":0,"max":10,"step":1,"x":370,"y":760,"wires":[["cede39fd.b940e8"]]},{"id":"c330a77b.500f58","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"ui_control","pt":"msg","to":"{\"min\":1,\"max\":$.duration}","tot":"jsonata"},{"t":"move","p":"progress","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":760,"wires":[["511f99e0.c089b8"]]},{"id":"d908d76d.5667d8","type":"spotify","z":"bd80cf37.f9982","name":"","auth":"[YOUR CONFIG - SPOTIFY]","api":"seek","x":790,"y":840,"wires":[[]]},{"id":"e86a673c.c09fa8","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"params","pt":"msg","to":"[payload]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":840,"wires":[["d908d76d.5667d8"]]},{"id":"cede39fd.b940e8","type":"rbe","z":"bd80cf37.f9982","name":"","func":"deadband","gap":"3000","start":"","inout":"in","property":"payload","x":540,"y":760,"wires":[["7bafa715.11bc28"]]},{"id":"4240c7f2.ebbae8","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"move","p":"payload.item.id","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":480,"wires":[["df71ed65.9b56d"]]},{"id":"7bafa715.11bc28","type":"trigger","z":"bd80cf37.f9982","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"1000","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":200,"y":840,"wires":[["6d55f578.603afc"]]},{"id":"6d55f578.603afc","type":"rbe","z":"bd80cf37.f9982","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":390,"y":840,"wires":[["e86a673c.c09fa8"]]},{"id":"19eb810.cf58c7f","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"minutes","pt":"msg","to":"(payload/60)-((payload/60)%1)","tot":"jsonata"},{"t":"set","p":"seconds","pt":"msg","to":"(payload%60)","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"params","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":940,"wires":[["fa04b5d9.0f1728"]]},{"id":"fa04b5d9.0f1728","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"move","p":"minutes","pt":"msg","to":"payload[0]","tot":"msg"},{"t":"move","p":"seconds","pt":"msg","to":"payload[1]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":940,"wires":[["d7f74681.e827d8"]]},{"id":"229a5d9.b0261a2","type":"ui_text","z":"bd80cf37.f9982","group":"4c99ccf8.ce4ef4","order":10,"width":"2","height":"1","name":"total","label":"","format":"{{msg.payload}}","layout":"row-spread","x":790,"y":940,"wires":[]},{"id":"f1ffcbe7.256788","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"set","p":"minutes","pt":"msg","to":"(payload/60)-((payload/60)%1)","tot":"jsonata"},{"t":"set","p":"seconds","pt":"msg","to":"(payload%60)","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"params","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":1000,"wires":[["958bbb69.850008"]]},{"id":"958bbb69.850008","type":"change","z":"bd80cf37.f9982","name":"","rules":[{"t":"move","p":"minutes","pt":"msg","to":"payload[0]","tot":"msg"},{"t":"move","p":"seconds","pt":"msg","to":"payload[1]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1000,"wires":[["53842c0a.bbc1d4"]]},{"id":"959827e4.4332b8","type":"ui_text","z":"bd80cf37.f9982","group":"4c99ccf8.ce4ef4","order":8,"width":"2","height":"1","name":"current","label":"","format":"{{msg.payload}}","layout":"row-spread","x":790,"y":1000,"wires":[]},{"id":"53842c0a.bbc1d4","type":"range","z":"bd80cf37.f9982","minin":"0","maxin":"60","minout":"0","maxout":"60","action":"scale","round":true,"property":"payload[1]","name":"","x":630,"y":1000,"wires":[["959827e4.4332b8"]]},{"id":"d7f74681.e827d8","type":"range","z":"bd80cf37.f9982","minin":"0","maxin":"60","minout":"0","maxout":"60","action":"scale","round":true,"property":"payload[1]","name":"","x":630,"y":940,"wires":[["229a5d9.b0261a2"]]},{"id":"[YOUR CONFIG - SPOTIFY]","type":"spotify-auth","z":"","name":"Spotify_ext OAuth2","scope":"user-read-playback-state\nstreaming\nplaylist-read-collaborative\nuser-modify-playback-state\nuser-library-modify\nuser-read-currently-playing\nplaylist-read-private\napp-remote-control\nplaylist-modify-private\nuser-library-read"},{"id":"[YOUR CONFIG]","type":"mqtt-broker","z":"","name":"test","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"4c99ccf8.ce4ef4","type":"ui_group","z":"","name":"Spotify","tab":"4007f45b.b0a3cc","disp":false,"width":"12","collapse":false},{"id":"4007f45b.b0a3cc","type":"ui_tab","z":"","name":"Spotify","icon":"my_library_music","disabled":false,"hidden":false}]

Flow Info

Created 4 years, 6 months ago
Updated 4 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x14)
  • debug (x4)
  • inject (x5)
  • mqtt in (x2)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • range (x2)
  • rbe (x4)
  • switch (x1)
  • trigger (x1)
Other
  • spotify (x7)
  • spotify-auth (x1)
  • tab (x1)
  • ui_button (x2)
  • ui_group (x1)
  • ui_numeric (x2)
  • ui_slider (x1)
  • ui_switch (x1)
  • ui_tab (x1)
  • ui_template (x1)
  • ui_text (x3)

Tags

  • spotify
  • control
  • dashboard
  • homeautomation
  • player
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option