I've also read that mice somehow feel the electrical voltages with their whiskers, and are scared away.
So, I really like Pommie's suggestion. Place the bait surrounded by IR sensors.
Once that a rat is sensed, wait a couple of seconds tho ensure that the rat is not just sniffing around, and then....zzaaaaaaaaaappp!
I would use a discarded microwave oven transformer as the zapping source. Those have sufficient voltage and current to completely fry a rat with a quick zap.
Return to idle afterwards.
All of this can be done with the IR sensors, some timers and a few discrete logic gates. Plus a power relay to drive the MOT.
Or if you are proficient with code, a single microcontroller plus some ancillary components will do.