[gcode_button am312] pin: !PC0 press_gcode: _motion_detected [gcode_macro _motion_detected] description: Motion sensor triggered gcode: {% set printing = printer.print_stats.state == "printing" %} # RESPOND MSG="AM312: Motion detected" {% if printing %} # RESPOND MSG="AM312: Printer is printing -> light ON (100%)" SET_PIN PIN=caselight VALUE=1.0 _set_nozzle_leds_on {% else %} # RESPOND MSG="AM312: Printer idle -> light ON (10%)" SET_PIN PIN=caselight VALUE=0.1 _set_nozzle_leds_off {% endif %} # RESPOND MSG="AM312: Resetting timeout to 30 seconds" UPDATE_DELAYED_GCODE ID=_motion_timeout DURATION=30 [delayed_gcode _motion_timeout] gcode: {% set printing = printer.print_stats.state == "printing" %} # RESPOND MSG="AM312: Timeout reached, no motion" {% if printing %} # RESPOND MSG="AM312: Printing -> dim light to 10%" SET_PIN PIN=caselight VALUE=0.1 {% else %} # RESPOND MSG="AM312: Idle -> light OFF" SET_PIN PIN=caselight VALUE=0.0 {% endif %} _set_nozzle_leds_off