Query printer status information

I didn’t see another way to do this so here is a macro I use to debug certain things or just query info I’m curious about. I don’t know of any info off hand that is more than 3 lists deep but it would be easy to add.

Use: PSTATUS S1="gcode_macro start_level"
Console output: // {'continue_test': True}

PSTATUS S1=extruder S2=can_extrude
// False

PSTATUS S1=toolhead S2=position S3=e
// 100.0

PSTATUS
// Idle

[gcode_macro PSTATUS]
gcode:
    {% if params.S3 %}
    {% set info = printer[params.S1][params.S2][params.S3] %}
    {% elif params.S2 %}
    {% set info = printer[params.S1][params.S2] %}
    {% elif params.S1 %}
    {% set info = printer[params.S1] %}
    {% else %}
    {% set	info = printer.idle_timeout.state %}
    {% endif %}
    {action_respond_info(info|string)}