Run a macro when klipper enters SHUTDOWN state

Hi,

I have a gcode shell command macro SCREEN_OFF that blanks the screen and II would like it to run whenever klipper enters the shutdown/error state.

Any way to do this?

Thanks

I don’t think that the control/dispatch loop is running anymore if Klipper is in the shutdown state. If the control loop is not running, there isn’t way to run the macro.

I’ll have to dig through the code to find out for sure.

I was thinking that to as you cant run macros while klipper is off, what about the moonraker power device executing the shell command?

so a moonraker power device can be bound to a service, would it be possible to have a service that does nothing except emit the required shell command on service stop?

Sure, I think that’s possible.