Hi, I did the same in a different way. I used a 433mhz proximity sensor such as this one. I added it to the door of this type of trap. The advantage is that it catches them alive. When the door closes, the 433mhz sensor gets separated from its base and it emits a signal. As the signal is only sent in case of movement, it is very battery friendly. The signal is caught by a 433Mhz receiver called Rflink connected to the rpi on which home assistant is, and sends a telegram notification. It works perfectly!
Here is my diy setup. Iām using a 433mhz door sensor but it can also be a zigbee one as well.
Just a coat hanger, water bottle and some scrap wood.
When the mouse tries to get back out of the bottle it tips down and the opening is blocked by the wood.
My automation sends me a notification when the bottle tips over.