diff --git a/Scripts/macros.cfg b/Scripts/macros.cfg index 70e4145..e426017 100644 --- a/Scripts/macros.cfg +++ b/Scripts/macros.cfg @@ -397,7 +397,7 @@ gcode: PID_CALIBRATE HEATER=heater_bed TARGET={T} -[gcode_macro PSTATUS] +[gcode_macro _PSTATUS] gcode: {% if params.S3 %} {% set info = printer[params.S1][params.S2][params.S3] %} @@ -409,3 +409,44 @@ gcode: {% set info = printer.idle_timeout.state %} {% endif %} {action_respond_info(info|string)} + +[gcode_macro _SEARCH_VARS] +gcode: + {% set search = params.S|lower %} + {% set ns = namespace() %} + {% for item in printer %} + {% if ' ' in item %} + {% set ns.path = ['printer', "['%s']" % (item), ''] %} + {% else %} + {% set ns.path = ['printer.', item, ''] %} + {% endif %} + + {% if search in ns.path|lower %} + { action_respond_info(ns.path|join) } + {% endif %} + + {% if printer[item].items() %} + {% for childkey, child in printer[item].items() recursive %} + {% set ns.path = ns.path[:loop.depth|int + 1] %} + + {% if ' ' in childkey %} + {% set null = ns.path.append("['%s']" % (childkey)) %} + {% else %} + {% set null = ns.path.append(".%s" % (childkey)) %} + {% endif %} + + {% if child is mapping %} + { loop(child.items()) } + {% else %} + {% if search in ns.path|lower %} + { action_respond_info("%s : %s" % (ns.path|join, child)) } + {% else %} + {% if search in child|lower %} + { action_respond_info("%s : %s" % (ns.path|join, child)) } + {% endif %} + {% endif %} + {% endif %} + + {% endfor %} + {% endif %} + {% endfor %} \ No newline at end of file