Basic Information:
Printer Model:
MCU / Printerboard:
Host / SBC
klippy.log
Fill out above information and in all cases attach your klippy.log
file (use zip to compress it, if too big). Pasting your printer.cfg
is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there
Describe your issue:
…
I’m trying to detect which filament sensor (sensor_filamento_0
or sensor_filamento_1
) triggered a runout and then use that information in my RESUME macro to purge and resume on the correct extruder. Here’s what I currently have:
# When sensor 0 trips:
SET_GCODE_VARIABLE MACRO=_PRINT_VARIABLE VARIABLE=runout_sensor VALUE='filament_switch_sensor sensor_filamento_0'
# Later in RESUME:
{% if "sensor_filamento_0" in runout_sensor %}
# purge and resume on extruder 0
{% elif "sensor_filamento_1" in runout_sensor %}
# purge and resume on extruder 1
{% endif %}
But ChatGPT suggested removing the embedded quotes to make it more robust and readable:
# Store without quotes:
SET_GCODE_VARIABLE MACRO=_PRINT_VARIABLE VARIABLE=runout_sensor VALUE=filament_switch_sensor sensor_filamento_0
# Then the same substring test still works:
{% if "sensor_filamento_0" in runout_sensor %}
…
{% endif %}
btw this is the variable:
[gcode_macro _PRINT_VARIABLE]
variable_runout_sensor : "" # Name of the filament sensor that triggered the error (configured from filament failure macros)
Wich aproach is the better?
Thanks