Run gcode before shutdown

What is the problem?

I need to be able to run cool down gcode commands before shutdown is initiated.
gcode:
M140 20 Bed cool down
M109 R50 Wait until hotend cools down to 50

run these before
image

Specifically, hitting shutdown from Octoprint, wait to cool before shutdown.

What did you already try to solve it?

Tried a couple of different event manager settings to no avail.

Have you tried running in safe mode?

N/A

Did running in safe mode solve the problem?

N/A

Systeminfo Bundle

N/A

Additional information about your setup

Highly modded Anet A6, with pc ps - RPi control, SONOFF S31 Lite Smart Plug wired to gpio, modified Marlin firmware, 2 cams, Text and email notification, custom fans and lighting, solid state x,y,z stop and runout switch.

Plugins:
cmd exec
Gcode system commands
GPIO control
Marlin Slider plugin
Multicam

Most simple way is to put these lines

either at the end of the end gcode in your slicer or in the
After print job completes slot in the OctoPrint GCODEscripts

That's if I am running a print, I have that already.

I need it before I shutdown via octoprint.

Note: I did try in the "Before serial connection to printer is closed".

1 Like

Does your printers firmware support action commands?

I found what I am looking for thanks to our fearless developer;
https://docs.octoprint.org/en/master/api/printer.html#send-an-arbitrary-command-to-the-printer

Thnaks

1 Like

I don't know... lol But thank you for your input. That's how I found the answer.

I would think that shutdown event in event manager would work, but I suppose that the serial connection is killed prior to the commands being sent. Which makes me think the GCODE Scripts for "Before serial connection to printer is closed" would have worked, but that might only be triggered if you click disconnect from the UI.

You are correct. That's what I thought too...

-JC

Glad you found a solution

My idea was a small gcode file with you commands and then the shot down host action command.

If you print this file it would send the commands to the printer and shut the pi down afterwards.

Obviously that's just a workaround and it's better to have a correct solution

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.