strayr / strayr-k-macros

useful macros to extend the functionality of klipper
GNU General Public License v3.0
143 stars 9 forks source link

Auto-power off printer when connected to wifi power plug #2

Open stephbellemare opened 2 years ago

stephbellemare commented 2 years ago

Thought it would be a good addition to your macro-set.
my printer is connected in a tp-link wifi power plug (you can use anything moonraker supports). this will; auto turn-off the printer after idle delay of 15 min

in printer.cfg you need to add this:

[delayed_gcode delayed_printer_off]
initial_duration: 0.
gcode:
   {% if printer.idle_timeout.state == "Idle" %}
      POWER_OFF_PRINTER
   {% endif %}

[idle_timeout]
timeout = 900
gcode:
   M18  
   TURN_OFF_HEATERS
   UPDATE_DELAYED_GCODE ID=delayed_printer_off DURATION=60

in the setup_macro file, i've added this

# Turn printer off
[gcode_macro POWER_OFF_PRINTER]
gcode:
   {action_call_remote_method("set_device_power", device="printer", state="off")}
strayr commented 2 years ago

I have relays on the AC side of the 24v PSU on my printers, I think adding a hook to power off at the end of a print is more use than doing so as an idle behaviour for me, particularly as I like to heatsoak the enclosure whilst I'm setting up the printer and don't want the bed heater turing off let alone the while printer. Your input is appreciated, and I will likely do something with it.

On Sat, 12 Mar 2022, 16:33 stephbellemare, @.***> wrote:

Thought it would be a good addition to your macro-set. my printer is connected in a tp-link wifi power plug (you can use anything moonraker supports). this will; auto turn-off the printer after idle delay of 15 min

in printer.cfg you need to add this:

[delayed_gcode delayed_printer_off] initial_duration: 0. gcode: {% if printer.idle_timeout.state == "Idle" %} POWER_OFF_PRINTER {% endif %}

[idle_timeout] timeout = 900 gcode: M18 TURN_OFF_HEATERS UPDATE_DELAYED_GCODE ID=delayed_printer_off DURATION=60

in the setup_macro file, i've added this

Turn printer off

[gcode_macro POWER_OFF_PRINTER] gcode: {action_call_remote_method("set_device_power", device="printer", state="off")}

— Reply to this email directly, view it on GitHub https://github.com/strayr/strayr-k-macros/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKIYU2H3SMEFZIUFXPGBKHLU7TBL3ANCNFSM5QSCYRVA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

stephbellemare commented 2 years ago

NP, just trying to help ;)