Is there a way to power on / off the printer using a relay? Maybe someone had set this up?
Haven’t got an Astrobox myself, but I just use a TP Link Kasa plug and IFTTT. Works great
Some of our printers include a feature for soft power down which can be triggered by gcode.
M80 for power on (at the beginning of the gcode) and
M81 for power down (at the end of the gcode).
It can be advisable to include a G4 S30 after the M80, to wait 30 seconds before executing the next code block. Likewise you may want to put another G4 S300 (or even longer) before the M80 to give your nozzle a chance to cool down before powering off, so that the heat doesn’t creep up your print head and melts the filament too far up.
Of course, worth mentioning that it only works when the printer is still receiving 5V from the AstroBox via the USB port.
Unfortunately doesn’t work with every printer, but tested successfully with Creality CR2020 and Anycubic Kossel Plus.
If you are looking for a real physical power off, I think Greg’s idea looks promising.