Thanks for the script, I will try it out.
I have further investigated the issue, and finally did realize, that the Z axis is binding at the top and first few mm of movement: moving the bed up or down by 0.5mm at the very top resulted in 0 movement. Replaced the springy couplings with solid ones that I had laying around, installed my BLTouch and it seems to now be working reliably. Still some work to do, but at least I can start a print without worries now.
I will rework my frame and look if there's any issues there, probably also get spider/rotex/plum couplings.
I also put my second Z motor on E1, which works great and will allow me to get tilt compensation working in the future.