Arksine / moonraker

Web API Server for Klipper
https://moonraker.readthedocs.io
GNU General Public License v3.0
1.02k stars 392 forks source link

Power device: add option to run custom gcode on on/off action #860

Open PhilippMolitor opened 1 month ago

PhilippMolitor commented 1 month ago

Is your feature request related to a problem? Please describe

When I power my device up or down (in my case, the 24V supply for motors and heaters), I want to have an option to run custom gcode before shutting off, and after turning on.

Describe the solution you'd like

Add the following options to any power device:

# macro block to execute after turning on the power device
on_gcode_gcode:
  MY_CUSTOM_OFF_MACRO
  M83
# run this macro 3 seconds after turning on
on_gcode_delay: 3
# macro block to execute after turning off the power device
on_gcode_gcode:
  MY_CUSTOM_ON_MACRO
  SOME_OTHER_MACRO
# run this macro 3 seconds before turning off
on_gcode_delay: 3

Describe alternatives you've considered

Adding a second power device for klipper does not seem reasonable, as I have to switch on two different devices then in the correct order.

Additional information

No response