Hello, der001mac. Thank you for using the Apple Support Communities, welcome! We understand that you have been noticing an issue when using your iMac where the Mac is waking from sleep unexpectedly. We know that being able to manage when your Mac is powered on must be important to you, and we can certainly help you with this situation.
We understand that you have already isolated the issue to one of the Bluetooth connections that your Mac has. We have several more suggestions that we think will help you continue from here.
For the next step, we would suggest reading over the following Apple Support article. This article contains information on what to do if you are noticing that your Mac either goes to sleep, or exits sleep mode unexpectedly:
If your Mac sleeps or wakes unexpectedly - Apple Support
If this seems to be caused by a Bluetooth connection, you can find steps to mange the system’s Bluetooth settings in the article above. According to the article:
"Bluetooth devices can wake your Mac. If you don’t want a Bluetooth keyboard or mouse to be able to wake the Mac, you can change your system’s Bluetooth settings.
Choose Apple menu > System Preferences, then click Bluetooth. Click Advanced, then deselect “Allow Bluetooth devices to wake this computer.”.”
If you continue to notice the same issue after this, we can help you more. To continue, it would be helpful to know if this same problem occurs after your Mac has been started in safe mode. Safe mode is a way we can isolate out the software that may be causing this issue. You can see how to use safe mode in this last article:
Start up your Mac in safe mode - Apple Support
If you still notice the same issue while in safe mode, please reply back here and we will be able to help you more with this.
We hope that this information helps you.
Have a great day!