BLTouch cannot set Z-height since Z Home is 5mm below bed

I ran one print. It ran fine. I ran a different file. It ran fine. I tried the same file again and the x shifted 17 mm shortly after the first layer. I stopped the print. When I attempted to restart it hours later, the home position for the Z was somewhere about 5 mm below the bed. I am unable to home the machine or set the Z-height now. What are the steps required to fix this?

What printer do you have, what version of ADVi3++, what version of BLTouch, etc…?

Maker Select Plus V4.06

BL Touch A3NPT 2YJS8 SMART V3.1

I had neglected to change the end gcode when I loaded Cura_SteamEngine 4.7.0. The first file was created with Cura_SteamEngine 4.6.1. The end codes are shown below.

End Gcode for first file that ended well:

;TIME_ELAPSED:1266.182784
G1 F1500 E841.59534
M140 S0
M107
; SC-10 Custom End G-code
G4 ; Wait
M220 S100 ; Reset Speed factor override percentage to default (100%)
M221 S100 ; Reset Extrude factor override percentage to default (100%)
G91 ; Set coordinates to relative
G1 F1800 E-3 ; Retract filament 3 mm to prevent oozing
G1 F3000 Z20 ; Move Z Axis up 20 mm to allow filament ooze freely
G90 ; Set coordinates to absolute
G1 X0 Y200 F1000 ; Move Heat Bed to the front for easy print removal
M84 ; Disable stepper motors
; End of custom end GCode
M82 ;absolute extrusion mode
M104 S0
;End of Gcode

End Gcode for second file before Z home problem:

;TIME_ELAPSED:13853.722534
G1 F1500 E1152.73701
M140 S0
M107
M104 S0 ;extruder heater off
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F120 ;move Z up a bit and retract filament even more
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
M84 ;steppers off
G90 ;absolute positioning
M82 ;absolute extrusion mode
M104 S0
;End of Gcode

I have recently changed the extruder and the head is below where it was previously. It was changed before the three prints mentioned above. I am not certain if that was before or after I changed the version of the ADVi3++ from version 4.03 to 4.06.

It is difficult to follow what you have done in which order.
Have you performed the z height tuning? What is your starting g code?

Starting Gcode in Cura:

G21 ;metric values
G90 ;absolute positioning
M82 ;set extruder to absolute mode
M107 ;start with the fan off
G28 X0 Y0 ;move X/Y to min endstops
G28 Z0 ;move Z to min endstops
G1 Z15.0 F{speed_travel} ;move the platform down 15mm
G92 E0 ;zero the extruded length
G1 F200 E6 ;extrude 6 mm of feed stock
G92 E0 ;zero the extruded length again
M280 P0 S160 ; BLTouch alarm release
G4 P100 ; delay for BLTouch
G28 ; home
G29 ; auto bed leveling
G1 F{speed_travel}
;Put printing message on LCD screen
M117 Printing…

Beginning of file:

;FLAVOR:Marlin
;TIME:13853
;Filament used: 13.6273m
;Layer height: 0.15
;MINX:54.94
;MINY:27.849
;MINZ:0.3
;MAXX:145.06
;MAXY:172.151
;MAXZ:10.35
;Generated with Cura_SteamEngine 4.7.0
M140 S90
M105
M190 S90
M104 S245
M105
M109 S245
M82 ;absolute extrusion mode
G21 ;metric values
G90 ;absolute positioning
M82 ;set extruder to absolute mode
M107 ;start with the fan off
G28 X0 Y0 ;move X/Y to min endstops
G28 Z0 ;move Z to min endstops
G1 Z15.0 F120 ;move the platform down 15mm
G92 E0 ;zero the extruded length
G1 F200 E6 ;extrude 6 mm of feed stock
G92 E0 ;zero the extruded length again
M280 P0 S160 ; BLTouch alarm release

G4 P100 ; delay for BLTouch
G28 ; home
G29 ; auto bed leveling
G1 F120
;Put printing message on LCD screen
M117 Printing…
G92 E0
G92 E0
G1 F1500 E-1.7

I have moved the BL Touch probe down. This has caused a tremendous change in the operation of the printer. It seems to be working now. I have had difficulty sending replies so things are out of sequence.