Since you're delving into conditional gcode you could look at something like this which only continues probing if necessary. Apologize for the length of this post but I included all sub macros for completeness. homexy.g also uses a virtual tool to indicate homing is in progress to avoid unnecessary Z axis movement. In case you're wondering, the sub macros are used to reduce duplicate code and unnecessarily updating several macros.
if !move.axes.homed || !move.axes.homed ; If the printer hasn't been homed, home it M98 P"0:/sys/homeyx.g" ; home y and x ; M98 P"0:/sys/homez.g" ; always home z ; M561 ; clear any bed transform M558 P9 H5 F120 T24000 ; increase dive height incase bed is severely out of alignment M98 P"bed_threeScrews.g" ; perform bed tramming echo "Bed Tramming Cycle: 1 - Difference was " ^ move.calibration.initial.deviation ^ "mm" ; M98 P"0:/macros/Utilities/Config/bltouch_config" ; Apply default BLTouch config ; while move.calibration.initial.deviation >= 0.01 ; perform additional tramming if previous deviation was over 0.01mm if iterations = 5 abort "Too many auto tramming attempts" M98 P"bed_threeScrews.g" ; perform bed tramming echo "Bed Tramming Cycle: " ^ iterations + 2 ^ " - Difference was " ^ move.calibration.initial.deviation ^ "mm" continue ; G28 Z ; home z
M558 P9 C"^io7.in" H2 F120 T24000 ; set Z probe type to bltouch and the dive height + speeds ; M98 P"0:/macros/Utilities/Config/bltouch_offset_config"
; ; G31 - +Z Nozzle closer to bed, -Z Nozzle further from bed ; G31 X0 Y-20.23 Z2.1 P500 ; 200710 mosquito liquid
G30 P0 X10 Y18 Z-99999 ; probe near a front left leadscrew G30 P1 X10 Y300 Z-99999 ; probe near a back left leadscrew G30 P2 X320 Y166 Z-99999 S3 ; probe near a right leadscrew and level
; homeyx.g ; called to home x and y axes ; ; Warning: do not home individual axes by calling G28 X or G28 Y. It will cause errors. Instead run the macro file directly. IE M98 P"0:/sys/homex.g" ; M563 P9 S"HomeAll" ; create tool 9 to indicate homeall is in progress ; G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position M98 P"0:/sys/homey.g" ; home y M98 P"0:/sys/homex.g" ; home x G90 ; absolute positioning ; M563 P9 D-1 H-1 ; delete tool 9 to indicate homeall is done
if #tools != 10 ; not homeall? G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position ; G1 H1 X357 F6000 ; move quickly to X axis endstop and stop there (first pass) G1 X-5 F3600 ; go back a few mm G1 H1 X357 F360 ; move slowly to X axis endstop once more (second pass) ; if #tools != 10 ; not homeall? G1 Z-5 F6000 H2 ; lower Z again G90 ; absolute positioning
if #tools != 10 ; not homeall? G91 ; relative positioning G1 Z5 F6000 H2 ; lift Z relative to current position G90 ; absolute positioning ; ; Home Z - inline with autolevel axis G1 X165 Y193 F24000 ; go to middle of the bed probe point and home Z. BLTouch on right M558 F1200 ; Set probing at faster feed rate G30 ; quickly home Z by probing the bed M400 ; clear buffer M98 P"0:/macros/Utilities/Config/bltouch_config" ; Return bltouch to defaults G30 ; slowly home Z by probing the bed M400 ; clear buffer