Rat trap
We have a somewhat elaborate rat trap in the basement. The code is in git.

Operating the trap
Setting it up
To set up the trap, first make sure all cables are connected properly and the two light sensors sit well on the holes in the case. Open the gate and put bait at the very end of the inside of the trap. Put the slit of the gate on the arm of the motor, so that the arm can move freely when retreating to close the gate (the arm will move in the direction where it takes the least amount of distance to close the gate). Put the second magnet under the trap, exactly under the position the magnet of the gate will be when the gate is closed. Plug everything in.
If the trap is within WiFi range (of kanthaus-gast) and nothing is broken, a message should be sent to the Mattermost channel Rat Trap.
Catching the rodent
When something caused the trap to close (e.g. a rat), again a message is sent on Mattermost. Also you can observe that it went off by the closed gate. Note that sometimes other things / people cause the gate to close without it going off; sometimes the trap also thinks there was something without that being the case.
Freeing the rodent
It's a tricky question where to put the rat. The problem is that we don't want it coming back, but we also don't want to kill it. For it not to come back, it should be safe to bring it about 3km away. For it not to die it needs it's family though; so for it to find its way back it should not be brought away more than 100m. So far we made the decision in favor of the rat not coming back.
To open the trap, first remove the magnet from under the trap, by sliding it to the front. Not doing this will likely break the gate. Then you can pull the gate up. Be careful not to get bitten by the rat!
Afterwards you can clean the trap and set it up again following the steps from the Setting it up section. Make sure not to damage the electronics when cleaning the trap!