@brasse I'd suspect the wiring; it sounds like something is 'floating', or perhaps the filament is not pushing the switch down fully. Though could be a similar issue as in this thread (similar hardware) https://forum.duet3d.com/topic/14014/openbuilds-limit-switch-reads-hit-in-s1-and-s0
For connecting it up (and do check the wiring), see https://duet3d.dozuki.com/Wiki/Connecting_endstop_switches#Section_Makerbot_Mechanical_Endstop_v1_Num_2
Edit: from the above page:
These devices produce an active-low output. If using RepRapFirmware 1.x or 2.x, use the S0 parameter in your M574 command
I think you need to invert the switch logic. The above is for M574, which defines endstops. With M591 you invert by sending P2, so in RRF3 I think your command should be :
M591 D0 P2 C"e0_stop" S1 ; filament monitor connected to E0_stop
Ian