@jay_s_uk Thanks for your reply.
The switch won't be moving - its within the limits of the gantry movement but to the left of the print surface. It is just a standard microswitch with a metal actuator.
My plan was to have the machine pick up tool0, have the bed rise to hit the switch three times, make an average of the offset and then put the tool back and pick tool1 up and do the same.
Ideally then each tool would have a -z offset from 0 that I can put into the config.g so that the Z heights are accurate.
Thanks for the link, I'll check that out.