One solution is an opto slot phototransistor and a comparator. That has no hysteresis and doesn't impede the movement.

Problem is keeping it clean and dry