Skip to content

Instantly share code, notes, and snippets.

@gelo2002
Created January 31, 2020 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gelo2002/1727790dfc3f6bac8c5b39f5a952b804 to your computer and use it in GitHub Desktop.
Save gelo2002/1727790dfc3f6bac8c5b39f5a952b804 to your computer and use it in GitHub Desktop.
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
}
]
@ronnyhartenstein
Copy link

Thank you! I've learnt a lot from it!

@chris2cant
Copy link

Good job !

@chris2cant
Copy link

I propose a fix to avoid error every second if your spotify is not playing.
I add a switch and a delay to retry every 1 minute if myCurrentPlayingTrack return {}

[{"id":"ed070e6f.91847","type":"tab","label":"Spotify","disabled":false,"info":""},{"id":"f3b1e952.8aba58","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"getMyCurrentPlayingTrack","x":520,"y":180,"wires":[["bd959065.93982","aeeff276.b8c3a"]]},{"id":"b44985f6.9ac4a8","type":"inject","z":"ed070e6f.91847","name":"Start","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":"1","x":210,"y":120,"wires":[["155473e5.f6505c"]]},{"id":"5a0040e6.50059","type":"mqtt out","z":"ed070e6f.91847","name":"","topic":"spotify","qos":"","retain":"","broker":"43bf5640.38c5c8","x":1230,"y":220,"wires":[]},{"id":"abdd24da.d7cc78","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.item.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":220,"wires":[["5a0040e6.50059"]]},{"id":"b717108d.dd01d","type":"ui_text","z":"ed070e6f.91847","group":"e6513e29.e9fa2","order":4,"width":0,"height":0,"name":"","label":"Track","format":"{{msg.payload.item.name}}","layout":"col-center","x":1030,"y":260,"wires":[]},{"id":"b1f5875a.cd84f8","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"skipToNext","x":470,"y":320,"wires":[[]]},{"id":"f419f7e6.02acd8","type":"ui_button","z":"ed070e6f.91847","name":"","group":"e6513e29.e9fa2","order":1,"width":"5","height":"1","passthru":false,"label":"Previous","tooltip":"","color":"","bgcolor":"","icon":"skip_previous","payload":"true","payloadType":"bool","topic":"","x":260,"y":400,"wires":[["80726f8b.bc098"]]},{"id":"80726f8b.bc098","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"skipToPrevious","x":480,"y":360,"wires":[[]]},{"id":"99e0afdb.7c3a9","type":"ui_button","z":"ed070e6f.91847","name":"","group":"e6513e29.e9fa2","order":3,"width":"5","height":"1","passthru":false,"label":"Next","tooltip":"","color":"","bgcolor":"","icon":"skip_next","payload":"true","payloadType":"bool","topic":"","x":270,"y":280,"wires":[["b1f5875a.cd84f8"]]},{"id":"72fec6d7.651608","type":"mqtt in","z":"ed070e6f.91847","name":"","topic":"spotify.next","qos":"2","datatype":"auto","broker":"43bf5640.38c5c8","x":260,"y":240,"wires":[["b1f5875a.cd84f8"]]},{"id":"e24ce412.c3a428","type":"mqtt in","z":"ed070e6f.91847","name":"","topic":"spotify.prev","qos":"2","datatype":"auto","broker":"43bf5640.38c5c8","x":260,"y":440,"wires":[["80726f8b.bc098"]]},{"id":"4a9f2db5.0feef4","type":"ui_template","z":"ed070e6f.91847","group":"e6513e29.e9fa2","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":1040,"y":300,"wires":[[]]},{"id":"e13bf093.ef9ea","type":"ui_switch","z":"ed070e6f.91847","name":"Play/Pause","label":"","tooltip":"","group":"e6513e29.e9fa2","order":2,"width":"2","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":810,"y":420,"wires":[["fa47cf2d.4b97d"]]},{"id":"5ba3efe0.b32a6","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"move","p":"payload.is_playing","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":360,"wires":[["e13bf093.ef9ea"]]},{"id":"43087ff3.dd733","type":"switch","z":"ed070e6f.91847","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":790,"y":520,"wires":[["73041cd7.ebfce4"],["1fe10a60.bb01b6"]]},{"id":"73041cd7.ebfce4","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"play","x":950,"y":500,"wires":[[]]},{"id":"1fe10a60.bb01b6","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"pause","x":950,"y":540,"wires":[[]]},{"id":"fa47cf2d.4b97d","type":"rbe","z":"ed070e6f.91847","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":950,"y":420,"wires":[["43087ff3.dd733"]]},{"id":"6a80f71e.e20008","type":"inject","z":"ed070e6f.91847","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":790,"y":560,"wires":[["1fe10a60.bb01b6"]]},{"id":"2edb137d.09eb4c","type":"inject","z":"ed070e6f.91847","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":790,"y":480,"wires":[["73041cd7.ebfce4"]]},{"id":"e249695.f07d098","type":"inject","z":"ed070e6f.91847","name":"Next","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":320,"wires":[["b1f5875a.cd84f8"]]},{"id":"e038d181.ae4f5","type":"inject","z":"ed070e6f.91847","name":"Prev","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":360,"wires":[["80726f8b.bc098"]]},{"id":"e99c760f.16efd8","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"getTrack","x":660,"y":720,"wires":[["11ab7631.0dff2a","4aa3c448.350f3c","200d6610.49123a"]]},{"id":"11ab7631.0dff2a","type":"debug","z":"ed070e6f.91847","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":890,"y":680,"wires":[]},{"id":"2f4ec9af.c41c46","type":"rbe","z":"ed070e6f.91847","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":670,"y":620,"wires":[["6b7bf4cf.aa302c"]]},{"id":"4aa3c448.350f3c","type":"debug","z":"ed070e6f.91847","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"params","targetType":"msg","x":890,"y":720,"wires":[]},{"id":"6b7bf4cf.aa302c","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"set","p":"params","pt":"msg","to":"[payload]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":720,"wires":[["e99c760f.16efd8"]]},{"id":"4cc20eda.e79b3","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"move","p":"payload.progress_ms","pt":"msg","to":"progress","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":780,"wires":[["a776af68.457f6","56198adb.3672f4"]]},{"id":"200d6610.49123a","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"move","p":"payload.duration_ms","pt":"msg","to":"duration","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":820,"wires":[["eea7370a.6fa1a8","56198adb.3672f4"]]},{"id":"ccfe89f2.b82ae8","type":"ui_numeric","z":"ed070e6f.91847","d":true,"name":"","label":"progress","tooltip":"","group":"e6513e29.e9fa2","order":6,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"100","step":1,"x":920,"y":780,"wires":[[]]},{"id":"a776af68.457f6","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"progress/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":780,"wires":[["ccfe89f2.b82ae8","87f5b294.4d2e4"]],"outputLabels":["seconds"]},{"id":"eea7370a.6fa1a8","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"duration/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":820,"wires":[["266ea98.6c45656","dfaaa1da.da423"]],"outputLabels":["seconds"]},{"id":"266ea98.6c45656","type":"ui_numeric","z":"ed070e6f.91847","d":true,"name":"","label":"duration","tooltip":"","group":"e6513e29.e9fa2","order":7,"width":0,"height":0,"wrap":true,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"100","step":1,"x":920,"y":820,"wires":[[]]},{"id":"39393bac.b7e764","type":"ui_slider","z":"ed070e6f.91847","name":"","label":"","tooltip":"","group":"e6513e29.e9fa2","order":9,"width":"8","height":"1","passthru":true,"outs":"end","topic":"","min":0,"max":10,"step":1,"x":510,"y":900,"wires":[["2f1d0348.87334c"]]},{"id":"56198adb.3672f4","type":"change","z":"ed070e6f.91847","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":320,"y":900,"wires":[["39393bac.b7e764"]]},{"id":"2759dc91.cb5ae4","type":"spotify","z":"ed070e6f.91847","name":"","auth":"88e3207f.1a3c2","api":"seek","x":930,"y":980,"wires":[[]]},{"id":"ab9fb1b6.141ef","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"set","p":"params","pt":"msg","to":"[payload]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":980,"wires":[["2759dc91.cb5ae4"]]},{"id":"2f1d0348.87334c","type":"rbe","z":"ed070e6f.91847","name":"","func":"deadband","gap":"3000","start":"","inout":"in","property":"payload","x":680,"y":900,"wires":[["70eaec36.ce3b44"]]},{"id":"44e84981.908a28","type":"change","z":"ed070e6f.91847","name":"","rules":[{"t":"move","p":"payload.item.id","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":620,"wires":[["2f4ec9af.c41c46"]]},{"id":"70eaec36.ce3b44","type":"trigger","z":"ed070e6f.91847","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"1000","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":340,"y":980,"wires":[["421ca2ec.fa1ddc"]]},{"id":"421ca2ec.fa1ddc","type":"rbe","z":"ed070e6f.91847","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":530,"y":980,"wires":[["ab9fb1b6.141ef"]]},{"id":"dfaaa1da.da423","type":"change","z":"ed070e6f.91847","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":380,"y":1080,"wires":[["b259c460.2cb938"]]},{"id":"b259c460.2cb938","type":"change","z":"ed070e6f.91847","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":600,"y":1080,"wires":[["9ab22f6b.cfb3c"]]},{"id":"7c468023.ef606","type":"ui_text","z":"ed070e6f.91847","group":"e6513e29.e9fa2","order":10,"width":"2","height":"1","name":"total","label":"","format":"{{msg.payload}}","layout":"row-spread","x":930,"y":1080,"wires":[]},{"id":"87f5b294.4d2e4","type":"change","z":"ed070e6f.91847","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":380,"y":1140,"wires":[["2c1c29b0.32b196"]]},{"id":"2c1c29b0.32b196","type":"change","z":"ed070e6f.91847","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":600,"y":1140,"wires":[["9ef3c606.97e6b8"]]},{"id":"b1f4cc34.88111","type":"ui_text","z":"ed070e6f.91847","group":"e6513e29.e9fa2","order":8,"width":"2","height":"1","name":"current","label":"","format":"{{msg.payload}}","layout":"row-spread","x":930,"y":1140,"wires":[]},{"id":"9ef3c606.97e6b8","type":"range","z":"ed070e6f.91847","minin":"0","maxin":"60","minout":"0","maxout":"60","action":"scale","round":true,"property":"payload[1]","name":"","x":770,"y":1140,"wires":[["b1f4cc34.88111"]]},{"id":"9ab22f6b.cfb3c","type":"range","z":"ed070e6f.91847","minin":"0","maxin":"60","minout":"0","maxout":"60","action":"scale","round":true,"property":"payload[1]","name":"","x":770,"y":1080,"wires":[["7c468023.ef606"]]},{"id":"4652e0f2.282d4","type":"debug","z":"ed070e6f.91847","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":620,"wires":[]},{"id":"bd959065.93982","type":"switch","z":"ed070e6f.91847","name":"","property":"payload","propertyType":"msg","rules":[{"t":"nempty"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":260,"wires":[["44e84981.908a28","4cc20eda.e79b3","5ba3efe0.b32a6","4a9f2db5.0feef4","b717108d.dd01d","abdd24da.d7cc78","155473e5.f6505c"],["db5adcd3.93cc5"]]},{"id":"155473e5.f6505c","type":"delay","z":"ed070e6f.91847","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":180,"wires":[["f3b1e952.8aba58"]]},{"id":"db5adcd3.93cc5","type":"delay","z":"ed070e6f.91847","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":80,"wires":[["f3b1e952.8aba58"]]},{"id":"aeeff276.b8c3a","type":"debug","z":"ed070e6f.91847","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":790,"y":180,"wires":[]},{"id":"88e3207f.1a3c2","type":"spotify-auth","z":"","name":"Spotify Full","scope":"ugc-image-upload\nuser-read-playback-state\nuser-modify-playback-state\nuser-read-currently-playing\nstreaming\napp-remote-control\nuser-read-email\nuser-read-private\nplaylist-read-collaborative\nplaylist-modify-public\nplaylist-read-private\nplaylist-modify-private\nuser-library-modify\nuser-library-read\nuser-top-read\nuser-read-playback-position\nuser-read-recently-played\nuser-follow-read\nuser-follow-modify"},{"id":"43bf5640.38c5c8","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":"e6513e29.e9fa2","type":"ui_group","z":"","name":"Spotify","tab":"bcdfcc32.a70e","disp":false,"width":"12","collapse":false},{"id":"bcdfcc32.a70e","type":"ui_tab","z":"","name":"Spotify","icon":"my_library_music","order":2,"disabled":false,"hidden":false}]

@mracer-node
Copy link

Hello, looks like fine.
But i didn' understand the connection to the mqtt broker. Spotify is installed on my Rasperry and reachable.
What must i write into the connection.
grafik

I got many errors like
12.1.2021, 10:57:58node: fcf67963.371c1msg : error
"TypeError: Cannot read property '1' of undefined"
12.1.2021, 10:57:59node: fcf67963.371c1msg : error
"TypeError: Cannot read property '1' of undefined"
12.1.2021, 10:58:00node: fcf67963.371c1msg : error
"TypeError: Cannot read property '1' of undefined"
12.1.2021, 10:58:01node: fcf67963.371c1msg : error
"TypeError: Cannot read property '1' of undefined"

Sorry for my English i'm German.
Thanks a lot

@gelo2002
Copy link
Author

Hallo @mracer-node,

Sorry for my English i'm German.
Thanks a lot
Kein Problem, ich spreche auch Deutch ;)

Um den Spotify-flow zum Laufen bringen braucht man eigentlich MQTT nicht.
Ich habe die MQTT Datagrams benutzt nur um die Kontrolle auf meinem Händy zu haben (habe ich einen MQTT Client auf em Händy installiert).
Du kannst alle MQTT Nodes entfernen und die Spotify Webpage wird auch gehen.

Falls Du die MQTT Kontrolle auch haben willst, musst du mehr Info geben, z.B. den Debug Node im "Complete Message Obejct" Mode umsetzen, dann sieht man nicht nur "payload" sondern auch alle restliche Signale. In dem originalem Flow habe ich so einen Node, mann muss es einfach an richtige Stelle anbinden: da wo die von Dir gennante Errors entstehen.
image

Beste Grüsse,
Grzegorz

@mracer-node
Copy link

mracer-node commented Jan 12, 2021 via email

@gelo2002
Copy link
Author

@mracer-node
Hallo Kalus,

Sorry, bin diese und nächste Woche unter dem Wasser mit meiner Arbeit.
Versuch bitte mit dem Debug-node in dem "Complete Message Object"-Mode und schreib hier in einem Kommentar was der Output war.

Grüsse
G

@mracer-node
Copy link

mracer-node commented Jan 13, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment