Skip to content

Instantly share code, notes, and snippets.

@schnello
Created April 16, 2019 11:53
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schnello/181318891d2bc2290e32213d1029a5b3 to your computer and use it in GitHub Desktop.
Save schnello/181318891d2bc2290e32213d1029a5b3 to your computer and use it in GitHub Desktop.
nodered flow for octoprint
[{"id":"4bedb5dd.1b0e8c","type":"change","z":"9d5bc26c.e42c8","name":"Set Progress 0","rules":[{"t":"set","p":"payload.progress.completion","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":300,"wires":[["e7dc5b91.a12e18"]]},{"id":"cea131b0.44184","type":"ui_template","z":"9d5bc26c.e42c8","group":"e2bbaa5d.0c6bf8","name":"Video Frame","order":1,"width":"10","height":"10","format":"<img width=\"16\" height=\"16\" src=\"{{flow.payload.webcam.on}}\" />","storeOutMessages":false,"fwdInMessages":true,"templateScope":"local","x":290,"y":580,"wires":[[]]},{"id":"8f572379.1bf63","type":"http request","z":"9d5bc26c.e42c8","name":"","method":"use","ret":"txt","url":"","tls":"","x":550,"y":60,"wires":[["27be8cd7.507f94"]]},{"id":"7bfde874.9bb6d8","type":"ui_gauge","z":"9d5bc26c.e42c8","name":"","group":"146f3617.73b19a","order":4,"width":"0","height":"0","gtype":"gage","title":"Heatbed","label":"","format":"{{msg.payload.temperature.bed.actual}}°C","min":0,"max":"110","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":880,"y":140,"wires":[]},{"id":"54e52141.4a3ae","type":"ui_gauge","z":"9d5bc26c.e42c8","name":"","group":"146f3617.73b19a","order":2,"width":"0","height":"0","gtype":"gage","title":"Nozzle","label":"","format":"{{msg.payload.temperature.tool0.actual}}°C","min":0,"max":"250","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":870,"y":100,"wires":[]},{"id":"e7dc5b91.a12e18","type":"ui_text","z":"9d5bc26c.e42c8","group":"146f3617.73b19a","order":1,"width":"2","height":"1","name":"","label":"Progress","format":"{{msg.payload.progress.completion | number:1}}%","layout":"row-left","x":840,"y":360,"wires":[]},{"id":"a3e0e022.0fa5c","type":"inject","z":"9d5bc26c.e42c8","name":"","topic":"I3_Mega","payload":"","payloadType":"date","repeat":"5","crontab":"","once":true,"onceDelay":"1","x":120,"y":40,"wires":[["6b0eeae6.bb40b4"]]},{"id":"60642249.51136c","type":"file in","z":"9d5bc26c.e42c8","name":"","filename":"apikey","format":"utf8","chunk":false,"sendError":false,"x":110,"y":420,"wires":[["f1e19511.bc1fb8"]]},{"id":"1a10b3b4.0e0f4c","type":"inject","z":"9d5bc26c.e42c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":360,"wires":[["60642249.51136c"]]},{"id":"2cae20ae.886ab","type":"comment","z":"9d5bc26c.e42c8","name":"Load Config","info":"Read in the API Key and save the valua to an global var\nContent of the file:\n{\n \"apikey\": \"Octoprint API Key\",\n \"ip\": \"192.168.1.210\",\n \"port\": \"5000\"\n}\n","x":90,"y":320,"wires":[]},{"id":"7200028a.0b157c","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"19cc90c.c3b236f","order":1,"width":0,"height":0,"passthru":false,"label":"+Y","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"commands\": [ \"G91\",\"G0 Y10 F3000\" ] }","payloadType":"json","topic":"","x":410,"y":340,"wires":[["bd1e3696.3d7518"]]},{"id":"7cf11045.41494","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"19cc90c.c3b236f","order":4,"width":0,"height":0,"passthru":false,"label":"-X","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"commands\": [ \"G91\",\"G0 X-10 F3000\" ] }","payloadType":"json","topic":"","x":410,"y":380,"wires":[["bd1e3696.3d7518"]]},{"id":"65084ad8.8db6a4","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"19cc90c.c3b236f","order":3,"width":0,"height":0,"passthru":false,"label":"+X","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"commands\": [ \"G91\",\"G0 X10 F3000\" ] }","payloadType":"json","topic":"","x":410,"y":420,"wires":[["bd1e3696.3d7518"]]},{"id":"705ac0d3.d6d28","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"19cc90c.c3b236f","order":2,"width":0,"height":0,"passthru":false,"label":"-Y","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"commands\": [ \"G91\",\"G0 Y-10 F3000\" ] }","payloadType":"json","topic":"","x":410,"y":460,"wires":[["bd1e3696.3d7518"]]},{"id":"90cafd0b.a0307","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"19cc90c.c3b236f","order":5,"width":0,"height":0,"passthru":false,"label":"Nozzle Up","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"commands\": [ \"G91\",\"G0 Z10 F100\" ] }","payloadType":"json","topic":"","x":430,"y":500,"wires":[["bd1e3696.3d7518"]]},{"id":"e9fc5412.ee36e8","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"19cc90c.c3b236f","order":6,"width":0,"height":0,"passthru":false,"label":"Nozzle Down","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"commands\": [ \"G91\",\"G0 Z-10 F100\" ] }","payloadType":"json","topic":"","x":430,"y":540,"wires":[["bd1e3696.3d7518"]]},{"id":"f1e19511.bc1fb8","type":"json","z":"9d5bc26c.e42c8","name":"","property":"payload","action":"","pretty":true,"x":110,"y":480,"wires":[["9202b82.52bea48"]]},{"id":"6b0eeae6.bb40b4","type":"function","z":"9d5bc26c.e42c8","name":"GET MESSAGE","func":"var apikey=flow.get('apikey') || 0;\nvar port=flow.get('port') || 0;\nvar ip=flow.get('ip') || 0;\nmsg.headers = {};\nmsg.headers={\n 'Content-type':'application/json',\n 'X-Api-Key': apikey };\nvar url1 = \"http://\" + ip + \":\" + port + \"/api/printer\";\nvar url2 = \"http://\" + ip + \":\" + port + \"/api/job\";\n\n\nvar msg1={\"method\":\"GET\",\"headers\":msg.headers,\"url\":url1,\"api\":\"PRINTER\"};\nvar msg2={\"method\":\"GET\",\"headers\":msg.headers,\"url\":url2,\"api\":\"JOB\"};\n\nreturn [ [ msg1 , msg2 ] ];\n\n","outputs":1,"noerr":0,"x":360,"y":60,"wires":[["8f572379.1bf63"]]},{"id":"9cedee0c.68cb3","type":"function","z":"9d5bc26c.e42c8","name":"POST MESSAGE","func":"var apikey=flow.get('apikey') || 0;\nvar port=flow.get('port') || 0;\nvar ip=flow.get('ip') || 0;\nmsg.method = \"POST\";\nmsg.headers = {};\nmsg.headers={\n 'Content-type':'application/json',\n 'X-Api-Key': apikey };\nmsg.url = \"http://\" + ip + \":\" + port + \"/api/printer/command\";\nreturn msg;\n","outputs":1,"noerr":0,"x":370,"y":100,"wires":[["8f572379.1bf63"]]},{"id":"bd1e3696.3d7518","type":"link out","z":"9d5bc26c.e42c8","name":"","links":["aba510e8.2596"],"x":555,"y":420,"wires":[]},{"id":"1b574876.2da928","type":"json","z":"9d5bc26c.e42c8","name":"","property":"payload","action":"","pretty":false,"x":710,"y":180,"wires":[["7bfde874.9bb6d8","54e52141.4a3ae","9ae65c43.4888c","24df9602.bbad2a","f9bc5b22.56d698"]]},{"id":"57d5fde3.e1ca44","type":"json","z":"9d5bc26c.e42c8","name":"","property":"payload","action":"","pretty":false,"x":630,"y":260,"wires":[["826015e4.9459b8"]]},{"id":"27be8cd7.507f94","type":"switch","z":"9d5bc26c.e42c8","name":"","property":"api","propertyType":"msg","rules":[{"t":"cont","v":"PRINTER","vt":"str"},{"t":"cont","v":"JOB","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":180,"wires":[["1b574876.2da928"],["57d5fde3.e1ca44"]]},{"id":"826015e4.9459b8","type":"switch","z":"9d5bc26c.e42c8","name":"","property":"payload.progress.completion","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":320,"wires":[["4bedb5dd.1b0e8c"],["e7dc5b91.a12e18"]]},{"id":"9202b82.52bea48","type":"function","z":"9d5bc26c.e42c8","name":"","func":"flow.set(\"ip\", msg.payload.ip);\nflow.set(\"port\", msg.payload.port);\nflow.set(\"apikey\", msg.payload.apikey);\nflow.set(\"webcam\", msg.payload.webcam);\nreturn msg;\n","outputs":1,"noerr":0,"x":130,"y":540,"wires":[["cea131b0.44184"]]},{"id":"f538656f.f67c38","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"1a42d6a4.152dd9","order":2,"width":0,"height":0,"passthru":false,"label":"Home","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"command\": \"G28\" }","payloadType":"json","topic":"","x":410,"y":300,"wires":[["bd1e3696.3d7518"]]},{"id":"a46ffeb1.4b2cd","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"4bcbe629.088de8","order":2,"width":0,"height":0,"passthru":false,"label":"Start Filament Change","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"command\": \"M600\" }","payloadType":"json","topic":"","x":200,"y":180,"wires":[["9cedee0c.68cb3"]]},{"id":"b0d10fc3.5ca82","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"4bcbe629.088de8","order":3,"width":0,"height":0,"passthru":false,"label":"Load Filament","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"command\": \"LOAD_FILAMENT\" }","payloadType":"json","topic":"","x":180,"y":220,"wires":[["9cedee0c.68cb3"]]},{"id":"55e2824.bc4817c","type":"ui_button","z":"9d5bc26c.e42c8","name":"","group":"4bcbe629.088de8","order":5,"width":0,"height":0,"passthru":false,"label":"RESUME","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"{ \"command\": \"RESUME_MACRO\" }","payloadType":"json","topic":"","x":160,"y":260,"wires":[["9cedee0c.68cb3"]]},{"id":"bec99e16.cefcc","type":"ui_chart","z":"9d5bc26c.e42c8","name":"","group":"1a42d6a4.152dd9","order":8,"width":"5","height":"5","label":"Nozzle Timeline","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1300,"y":260,"wires":[[]]},{"id":"9ae65c43.4888c","type":"change","z":"9d5bc26c.e42c8","name":"","rules":[{"t":"move","p":"msg.payload.temperature.tool0.actual","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":260,"wires":[["bec99e16.cefcc"]]},{"id":"24df9602.bbad2a","type":"ui_text","z":"9d5bc26c.e42c8","group":"1a42d6a4.152dd9","order":1,"width":"2","height":"1","name":"","label":"State","format":"{{msg.payload.state.text}}","layout":"row-left","x":870,"y":180,"wires":[]},{"id":"f9bc5b22.56d698","type":"function","z":"9d5bc26c.e42c8","name":"print check","func":"var state = msg.payload.state.flags.printing;\nvar msg1 = { background:\"green\",enabled: true };\nvar msg2 = { background:\"red\", enabled: false };\nif ( state === true ){\n global.set(\"state\",true);\n return [msg1,msg2];\n} else {\n global.set(\"state\",false);\n return [msg2,msg1];\n}","outputs":2,"noerr":0,"x":890,"y":220,"wires":[["b1d6eec1.e4d75"],["17d7a3e7.8d284c"]]},{"id":"b1d6eec1.e4d75","type":"link out","z":"9d5bc26c.e42c8","name":"out_print_active","links":["cf9a42aa.d6814"],"x":1095,"y":140,"wires":[]},{"id":"2b1fecc7.bfda84","type":"link in","z":"9d5bc26c.e42c8","name":"in_print_nonactive","links":["17d7a3e7.8d284c"],"x":240,"y":420,"wires":[["f538656f.f67c38","7200028a.0b157c","7cf11045.41494","65084ad8.8db6a4","705ac0d3.d6d28","90cafd0b.a0307","e9fc5412.ee36e8"]]},{"id":"cf9a42aa.d6814","type":"link in","z":"9d5bc26c.e42c8","name":"in_print_active","links":["b1d6eec1.e4d75"],"x":35,"y":220,"wires":[["55e2824.bc4817c","b0d10fc3.5ca82","a46ffeb1.4b2cd"]]},{"id":"17d7a3e7.8d284c","type":"link out","z":"9d5bc26c.e42c8","name":"out_print_inactive","links":["2b1fecc7.bfda84"],"x":1115,"y":200,"wires":[]},{"id":"aba510e8.2596","type":"link in","z":"9d5bc26c.e42c8","name":"Post_MESSAGE_IN","links":["953a2df4.46848","bd1e3696.3d7518"],"x":175,"y":100,"wires":[["9cedee0c.68cb3"]]},{"id":"53f09e37.68797","type":"template","z":"9d5bc26c.e42c8","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"apikey\": \"Octoprint_API_Key\",\n \"ip\": \"192.168.1.210\",\n \"port\": \"5000\",\n \"webcam\": \"http://127.0.0.1/video\"\n}","output":"json","x":260,"y":700,"wires":[["a4da53cd.8d64e"]]},{"id":"11b3f341.864c0d","type":"inject","z":"9d5bc26c.e42c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":700,"wires":[["53f09e37.68797"]]},{"id":"a4da53cd.8d64e","type":"file","z":"9d5bc26c.e42c8","name":"","filename":"apikey","appendNewline":true,"createDir":false,"overwriteFile":"true","x":430,"y":700,"wires":[[]]},{"id":"693525c4.8f080c","type":"comment","z":"9d5bc26c.e42c8","name":"Write Config","info":"Read in the API Key and save the valua to an global var\nContent of the file:\n{\n \"apikey\": \"Octoprint API Key\",\n \"ip\": \"192.168.1.210\",\n \"port\": \"5000\"\n}\n","x":110,"y":640,"wires":[]},{"id":"e2bbaa5d.0c6bf8","type":"ui_group","z":"","name":"Video Frame","tab":"d2fcb553.cdc188","disp":true,"width":"11","collapse":false},{"id":"146f3617.73b19a","type":"ui_group","z":"","name":"Temp","tab":"d2fcb553.cdc188","order":3,"disp":true,"width":"6","collapse":false},{"id":"19cc90c.c3b236f","type":"ui_group","z":"","name":"Move","tab":"d2fcb553.cdc188","order":4,"disp":true,"width":"6","collapse":false},{"id":"1a42d6a4.152dd9","type":"ui_group","z":"","name":"Control","tab":"d2fcb553.cdc188","order":2,"disp":true,"width":"6","collapse":false},{"id":"4bcbe629.088de8","type":"ui_group","z":"","name":"Fila Change","tab":"a182a07c.6161b","order":1,"disp":true,"width":"6","collapse":false},{"id":"d2fcb553.cdc188","type":"ui_tab","z":"","name":"I3 Mega","icon":"dashboard","order":15,"disabled":false,"hidden":false},{"id":"a182a07c.6161b","type":"ui_tab","z":"","name":"Filament Change","icon":"dashboard","order":4,"disabled":false,"hidden":false}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment