iMac sometimes refuses to go to sleep
About a month ago my 2009 iMac (OS X 10.6.8) started exhibiting an odd behavior: when I put the computer to sleep it immediately wakes back up again. Sometimes I have to put it to sleep several times (most recently more than a dozen) before it will finally stay that way. The computer has otherwise been problem-free, and it does not do this all the time; it seems unpredictable when it will happen. On a couple of occasions this was accompanied by the sudden appearance of “Bluetooth Setup Assistant” which was very puzzling as I use a wired mouse and keyboard and do not do anything with Bluetooth (the problem still happens if I turn it off). I don’t know whether that is related to the waking problem.
I had thought this might be related to an external hard drive I’ve been using for a while, but the problem is still going on after disconnecting that device.
Any thoughts about what might be causing this, and what to do about it?
iMac 24, Mac OS X (10.6.8)