Is there already a way to pause/continue/abort/restart a print directly from the printer menu? That would be really handy since I often don't have my notebook/phone nearby or running when taking a look at the current messed up print. I'm thinking of a new menu section in marlin that would send serial commands and thus trigger events in octoprint. Is there a protocol/specification for data pushed from the printer (like those temperature updates) and is it possible to process these in a plugin?
Klipper can do something like that. At least, I've seen the option on my own printer.
Yeah, got it. Here is my complete solution (since there is no native "start job" command):
- Python script to execute Octoprint API calls
#!/home/octoprint2/OctoPrint/bin/python
OCTOPRINT_URL = 'http://localhost:5001/api/'
API_KEY = '***'
import requests
import sys
port = sys.argv[1]
headers = {'X-Api-Key': API_KEY}
json = {
"command": sys.argv[1]
}
r = requests.post(
OCTOPRINT_URL + "job",
json=json,
headers=headers
)
if (r.status_code == 204):
json = {
"command": "M117 Octo \"" + sys.argv[1] + "\" done."
}
else:
json = {
"command": "M117 Octo \"" + sys.argv[1] + "\" failed."
}
r = requests.post(
OCTOPRINT_URL + "printer/command",
json=json,
headers=headers
)
- Custom Action commands plugin https://github.com/benlye/OctoPrint-ActionCommandsPlugin Setup:
action: octo_start | type: system | command: /path/to/script.py start
action: octo_cancel | type: system | command: /path/to/script.py cancel
- Marlin Configuration_adv.h
#define CUSTOM_USER_MENUS
#if ENABLED(CUSTOM_USER_MENUS)
#define USER_SCRIPT_DONE "M117 User Script Done"
#define USER_SCRIPT_AUDIBLE_FEEDBACK
#define USER_SCRIPT_RETURN // Return to status screen after a script
#define USER_DESC_1 "Octoprint Cancel"
#define USER_GCODE_1 "M118 //action:octo_cancel"
#define USER_DESC_2 "Octoprint Start"
#define USER_GCODE_2 "M118 //action:octo_start"
2 Likes