I am almost there with the homing file using conditional code.
if sensors.endstops[4].triggered && state.status.idle
M291 P"MMU loaded. Selector homing not allowed.Please unload MMU manually." S2
if sensors.endstops[4].triggered && state.status.printing
M25
M291 P"MMU loaded. Selector homing not allowed.Please unload MMU manually." S2
else
M913 U50 ; reduce motor current to 50% to prevent bad noises
M915 U S5 F0 ; set stall parameters
G91 ; use relative positioning
G1 H1 U5 F2000 ; move out 5mm
G1 H1 U-100 F1000 ; move carriage to home
G90 ; back to absolute positioning
M400 ; make sure everything has stopped before we reset the motor currents
M913 U100 ; motor currents back to normal
But , obviously is not working because state.status.idle is not the correct way of expressing the value of state.status.
Here is the state tree. Surely this is trivial for anyone who is used to any type of coding, not for me unfortunately.
Edit: state.status == "Idle" .