I am using a script call in the Event manager at Event "print done" to turn off the 3d printer via a smart socket. Before that I would like to disconnect the printer via the Event manager.
What is the correct command for this?
And sorry, probably the solution is so simple....
What did you already try to solve it?
I have searched the manual, this forum and the internet and unfortunately found no solution
I'm doing it via internal commands available in octoprint plugin environment. I'm not sure if OctoPrint's CLI has a disconnect command or not, but you could use it's API to do it with curl command.
Unfortunately the solution does not work as desired. The disconnect via curl works very well from the command line. But when it is executed by the Event Manager, nothing happens.
I have a number of debug logs turned on that have something to do with events. There I can see that the event is triggering. But unfortunately I can't see from this why the disconnect doesn't work.
I noticed that in config.yaml in the curl command a line break is inserted before the "-X". As soon as I change something in the event manager, it is inserted again, even if I manually remove the line break in config.yaml.However, this does not seem to be the problem, because the command is displayed completely in the log.
This morning I discovered an error message in the log that had escaped me until now:
2022-04-26 06:46:42,258 - octoprint.events - WARNING - There was an error processing one or more placeholders in the following command: curl -s -H "Content-Type: application/json" -H "X-Api-Key:blabla" -X POST -d '{ "command": "disconnect" }' http://localhost:5000/api/connection
But there are no placeholders in the curl command. Or what is meant by this?
I saw this recently on another post in regard to event manager and curl commands. You need to escape the '{ "command": "disconnect" }' bit somehow so that it's not seen as a replacement placeholder for string formatting I think. I'll see if I can find that post.