Use M119 to check the endstop state when triggered and untriggered.
Turns out one of the leads on my endstop came unplugged, should have known to check that.
The automatic checking of the endstop-states is an interesting idea. I'll see if I can implement it.