I have lots of projects that involve sensing when a door is opened/closed. Normally, I use a reed switch.
Someone suggested I try an slotted optical coupler ("optocoupler") instead. This
is a working experiment with that type of switch. See doc in main.py
for
details.