Good Ideas from talented indivudals

Goofballtech:

PeterH:
Why not orient the switch so that it does not present an end stop to the cap?

Interesting. How so?

Hard to know what PeterH had in mind but a lever microswitch held such that the rod passing it deflected the lever would be a very basic way:
____ | |
Sw |\ | |
___| | |
| |

An optical path broken by the rod would be another way.