Skip to content

Instantly share code, notes, and snippets.

@bakman2
Created November 25, 2019 21:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakman2/c9620337dfa8c3ac986bd64bbdd24558 to your computer and use it in GitHub Desktop.
Save bakman2/c9620337dfa8c3ac986bd64bbdd24558 to your computer and use it in GitHub Desktop.
OctoPrint API helper subflow

OctoPrint helper node

Configure the OctoPrint subflow node;

IP/hostname, API key.

Select an option to query from OctoPrint

Connected an inject node and a debug node Inject anything to get its status

[{"id":"4a0b6520.d97434","type":"subflow","name":"OctoPrint","info":"### Octoprint\n\nConfigure the node; IP/hostname, API key.\nSelect an option to query from OctoPrint\n\nConnected an inject node and a debug node\nInject anything\n","category":"","in":[{"x":44,"y":48,"wires":[{"id":"9803ec2a.54fff"}]}],"out":[{"x":572,"y":48,"wires":[{"id":"e2150a4b.e1878","port":0}]}],"env":[{"name":"url","type":"str","value":"192.168.1.1","ui":{"label":{"en-US":"http://"},"type":"input","opts":{"types":["str"]}}},{"name":"api","type":"str","value":"","ui":{"label":{"en-US":"API key"},"type":"input","opts":{"types":["str"]}}},{"name":"request","type":"str","value":"","ui":{"label":{"en-US":"Type"},"type":"select","opts":{"opts":[{"l":{"en-US":"Printer Operations"},"v":"printer"},{"l":{"en-US":"Jobs"},"v":"job"},{"l":{"en-US":"Files"},"v":"files"}]}}}],"color":"#C7E9C0","icon":"font-awesome/fa-print"},{"id":"38d52791.fadb2","type":"http request","z":"4a0b6520.d97434","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":286,"y":48,"wires":[["e2150a4b.e1878"]]},{"id":"9803ec2a.54fff","type":"function","z":"4a0b6520.d97434","name":"","func":"msg.headers = {'X-Api-Key': env.get(\"api\")}\nmsg.url = env.get(\"url\") +\"/api/\" + env.get(\"request\");\nreturn msg\n","outputs":1,"noerr":0,"x":146,"y":48,"wires":[["38d52791.fadb2"]]},{"id":"e2150a4b.e1878","type":"json","z":"4a0b6520.d97434","name":"","property":"payload","action":"","pretty":false,"x":458,"y":48,"wires":[[]]},{"id":"eb712bd7.ccf28","type":"inject","z":"2f92a3ee.a4ff34","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":288,"y":336,"wires":[["1ed4f35b.0f6845"]]},{"id":"1ed4f35b.0f6845","type":"subflow:4a0b6520.d97434","z":"2f92a3ee.a4ff34","name":"","x":480,"y":336,"wires":[["f281d24f.caa198"]]},{"id":"f281d24f.caa198","type":"debug","z":"2f92a3ee.a4ff34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":672,"y":336,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment