unknow electronic chirping devise on fan

I recently did an inspection and came across this electronic chirping devise hooked up to the ceiling fan. When the light was switched on the devise would chirp through what looked like a little speaked. Sometimes it would chirp once, sometimes twice, sometimes 3 or 4 times. I’ve never seen anything like it. OK maybe a high frequency devise designed to keep rodents out of a home. Any ideas on what this thing is??

It looks like a remote control unit for the fan. They sell them aftermarket and they are designed to fit inside the canopy but appears someone installed it on the outside. Not the same but you get the idea. http://www.homedepot.com/h_d1/N-5yc1v/R-202851042/h_d2/ProductDisplay?langId=-1&storeId=10051&catalogId=10053