Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Last active August 25, 2020 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrypisig/0abf23b104f13cb98725473a5c4980d1 to your computer and use it in GitHub Desktop.
Save raspberrypisig/0abf23b104f13cb98725473a5c4980d1 to your computer and use it in GitHub Desktop.
[{"id":"41fe5fcf.230f8","type":"tab","label":"media player","disabled":false,"info":""},{"id":"18502263.faee2e","type":"inject","z":"41fe5fcf.230f8","name":"NETWORK_EXPLORER","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"10","topic":"NETWORK_EXPLORER","payload":"http://192.168.20.99:8002","payloadType":"str","x":210,"y":160,"wires":[["a066cf65.6e121"]]},{"id":"cc0d39f1.734978","type":"debug","z":"41fe5fcf.230f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":60,"wires":[]},{"id":"153eec34.3f0de4","type":"http request","z":"41fe5fcf.230f8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":650,"y":200,"wires":[["3ad66e1.9686e92"]]},{"id":"a066cf65.6e121","type":"function","z":"41fe5fcf.230f8","name":"","func":"msg.url = msg.payload + \"/api/directories\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":220,"wires":[["153eec34.3f0de4"]]},{"id":"3ad66e1.9686e92","type":"function","z":"41fe5fcf.230f8","name":"","func":"folders = [\"--SELECT--\"];\n\nmsg.payload.forEach(elem => {\n folders.push(elem.short);\n});\n\nfolders.push(\"--BACK--\");\n\nmsg.payload = {\n data : {\n options: folders\n }\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":320,"wires":[["cc0d39f1.734978","76c94ad3.2adbf4"]]},{"id":"76c94ad3.2adbf4","type":"api-call-service","z":"41fe5fcf.230f8","name":"","server":"c80fca71.e51228","version":1,"debugenabled":true,"service_domain":"input_select","service":"set_options","entityId":"input_select.lhs","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":620,"y":480,"wires":[["8c28a7a0.3b90d8","e683e412.c0c088"]]},{"id":"8c28a7a0.3b90d8","type":"debug","z":"41fe5fcf.230f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":500,"wires":[]},{"id":"e5dd0f5c.08b97","type":"server-state-changed","z":"41fe5fcf.230f8","name":"","server":"c80fca71.e51228","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":" input_select.lhs","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"-1","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"x":290,"y":740,"wires":[["e86e6d92.e2a1c","dd6bebf8.275c98"],[]]},{"id":"dd6bebf8.275c98","type":"debug","z":"41fe5fcf.230f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":390,"y":620,"wires":[]},{"id":"e683e412.c0c088","type":"function","z":"41fe5fcf.230f8","name":"","func":"if (msg.statusCode === 200) {\n msg.url = msg.url.replace(\"/api/directories\", \"\");\n global.set('baseURL', msg.url);\n global.set('selectedFolder', \"\");\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":890,"y":400,"wires":[[]]},{"id":"e86e6d92.e2a1c","type":"function","z":"41fe5fcf.230f8","name":"","func":"if (msg.payload == \"--SELECT--\") {\n return;\n}\n\nmsgs = [];\n\n\nvar selectedFolder = global.get('selectedFolder');\nvar baseURL = global.get('baseURL');\n\nif (msg.payload == \"--BACK--\") {\n if (selectedFolder===\"\") {\n \n }\n else {\n selectedFolder = selectedFolder.substring(0, selectedFolder.lastIndexOf('/'));\n }\n}\n\nelse {\n selectedFolder = selectedFolder + \"/\" + msg.payload; \n}\n\n\nglobal.set('selectedFolder', selectedFolder);\n\n\n\nvar fullURLdir = baseURL + \"/api/directories\" + selectedFolder;\nvar fullURLfiles = baseURL + \"/api/files\" + selectedFolder;\n\nvar msg1 = {};\nvar msg2 = {};\n\nmsg1.url = fullURLdir;\nmsg2.url = fullURLfiles;\n\n\nvar msgs = [msg1, msg2];\n\n\nreturn msgs;","outputs":2,"noerr":0,"initialize":"","finalize":"","x":220,"y":860,"wires":[["9730f69f.e343d8"],["81c53667.d61188"]]},{"id":"1826faa9.a71ea5","type":"function","z":"41fe5fcf.230f8","name":"","func":"folders = [\"--SELECT--\"];\n\nmsg.payload.forEach(elem => {\n folders.push(elem.short);\n});\n\nfolders.push(\"--BACK--\");\n\nmsg.payload = {\n data : {\n options: folders\n }\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":790,"y":740,"wires":[["46bcd44e.c21f6c"]]},{"id":"dd748976.0f4e08","type":"function","z":"41fe5fcf.230f8","name":"","func":"var files = [\"--SELECT--\"];\n\nmsg.payload.forEach(elem => {\n files.push(elem.short);\n});\n\n\nmsg.payload = {\n data : {\n options: files\n }\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":700,"y":920,"wires":[["afeedb22.9a4b88"]]},{"id":"985b4637.e2a1d8","type":"debug","z":"41fe5fcf.230f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1000,"y":740,"wires":[]},{"id":"a9b1f5c1.7bdb78","type":"debug","z":"41fe5fcf.230f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":940,"wires":[]},{"id":"9730f69f.e343d8","type":"http request","z":"41fe5fcf.230f8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":480,"y":820,"wires":[["1826faa9.a71ea5"]]},{"id":"81c53667.d61188","type":"http request","z":"41fe5fcf.230f8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":470,"y":920,"wires":[["dd748976.0f4e08"]]},{"id":"46bcd44e.c21f6c","type":"api-call-service","z":"41fe5fcf.230f8","name":"","server":"c80fca71.e51228","version":1,"debugenabled":true,"service_domain":"input_select","service":"set_options","entityId":"input_select.lhs","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":900,"y":640,"wires":[["985b4637.e2a1d8"]]},{"id":"afeedb22.9a4b88","type":"api-call-service","z":"41fe5fcf.230f8","name":"","server":"c80fca71.e51228","version":1,"debugenabled":true,"service_domain":"input_select","service":"set_options","entityId":"input_select.rhs","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":780,"y":1040,"wires":[["a9b1f5c1.7bdb78"]]},{"id":"bce45b98.9f2cd8","type":"server-state-changed","z":"41fe5fcf.230f8","name":"","server":"c80fca71.e51228","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":" input_select.rhs","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"-1","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"x":250,"y":1180,"wires":[["751b0540.09f5dc"],[]]},{"id":"f3471d17.65cbd","type":"debug","z":"41fe5fcf.230f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":1180,"wires":[]},{"id":"751b0540.09f5dc","type":"function","z":"41fe5fcf.230f8","name":"","func":"var fullURL = `${global.get('baseURL')}${global.get('selectedFolder')}/${msg.payload}`; \n\nmsg.payload = {\n data: {\n media_content_id: fullURL,\n media_content_type: \"music\"\n }\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":1220,"wires":[["f3471d17.65cbd","3f39e17c.1788ee"]]},{"id":"3f39e17c.1788ee","type":"api-call-service","z":"41fe5fcf.230f8","name":"","server":"c80fca71.e51228","version":1,"debugenabled":false,"service_domain":"media_player","service":"play_media","entityId":"media_player.rumpus_room_speaker","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":1300,"wires":[[]]},{"id":"c80fca71.e51228","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment