IMac randomly wakes up from sleep

imacmacossleep-wake

My iMac (27-inch, Late 2012) randomly wakes up, up to 9 times a day. I'm using El Capitan 10.11.3 (15D21).

A syslog | grep -i "Wake reason" shows the following many times:

Apr  5 00:02:50 Nikolajs-iMac kernel[0] <Notice>: Wake reason: EC.SleepTimer (SleepTimer)
Apr  5 00:02:52 Nikolajs-iMac kernel[0] <Notice>: [HID] [ATC] AppleDeviceManagementHIDEventService::processWakeReason Wake reason: Host (0x01)
Apr  6 18:55:24 Nikolajs-iMac kernel[0] <Notice>: Wake reason: EC.PME (User)
Apr  6 18:55:28 Nikolajs-iMac kernel[0] <Notice>: [HID] [ATC] AppleDeviceManagementHIDEventService::processWakeReason Wake reason: Host (0x01)
Apr  6 20:37:16 Nikolajs-iMac kernel[0] <Notice>: Wake reason: EC.SleepTimer (SleepTimer)
Apr  6 20:37:19 Nikolajs-iMac kernel[0] <Notice>: [HID] [ATC] AppleDeviceManagementHIDEventService::processWakeReason Wake reason: Host (0x01)
Apr  6 21:20:03 Nikolajs-iMac kernel[0] <Notice>: Wake reason: EHC1
Apr  6 21:20:04 Nikolajs-iMac kernel[0] <Notice>: [HID] [ATC] AppleDeviceManagementHIDEventService::processWakeReason Wake reason: Button (0x03)
Apr  6 22:31:19 Nikolajs-iMac kernel[0] <Notice>: Wake reason: EC.SleepTimer (SleepTimer)
Apr  6 22:31:21 Nikolajs-iMac kernel[0] <Notice>: [HID] [ATC] AppleDeviceManagementHIDEventService::processWakeReason Wake reason: Host (0x01)

There aren't any usb devices connected, nor any bluetooth devices, except the keyboard and mouse.

The most obvious reasons, power nap and wake on lan, aren't turned on. I've already tried to toggle them but it didn't help. What else could this be?

I've googled for answers for a long time, many times, already, but I couldn't find any solution to this. The problem already persists for at least two major OSX versions.

Thanks a lot!

Update:

➜  ~ pmset -g assertions
2016-04-12 18:30:18 +0200
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
Listed by owning process:
   pid 526(storedownloadd): [0x000049be000112c7] 143:31:30 PreventUserIdleSystemSleep named: "URLConnection in progress"
   pid 100(hidd): [0x0000bf4b00091335] 00:18:20 UserIsActive named: "com.apple.iohideventsystem.queue.tickle"
    Timeout will fire in 219 secs Action=TimeoutActionRelease
Kernel Assertions: 0x8=BT-HID
   id=501  level=255 0x8=BT-HID mod=01.01.70, 01:00 description=com.apple.driver.IOBluetoothHIDDriver owner=AppleHSBluetoothDevice
   id=502  level=255 0x8=BT-HID mod=01.01.70, 01:00 description=com.apple.driver.IOBluetoothHIDDriver owner=AppleBluetoothHIDKeyboard
Idle sleep preventers: IODisplayWrangler

Update 2: I managed to enter the pmset -g assertions right after the imac woke up last night. Here is the output:

➜  ~ pmset -g assertions
2016-04-16 22:40:16 +0200
Assertion status system-wide:
   BackgroundTask                 1
   ApplePushServiceTask           0
   UserIsActive                   0
   PreventUserIdleDisplaySleep    0
   InteractivePushServiceTask     1
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
   InternalPreventSleep           1
Listed by owning process:
   pid 62023(AddressBookSourceSync): [0x000159c300010639] 00:00:06 PreventUserIdleSystemSleep named: "Address Book Source Sync"
    Timeout will fire in 1794 secs Action=TimeoutActionTurnOff
   pid 204(backupd-helper): [0x000159c3000b062b] 00:00:06 BackgroundTask named: "backupd-helper"
   pid 186(coreaudiod): [0x000159c8000101e8] 00:00:00 PreventUserIdleSystemSleep named: "com.apple.audio.AppleHDAEngineOutput:1B,0,1,2:0.context.preventuseridlesleep"
    Created for PID: 249.
   pid 62024(AddressBookSourceSync): [0x000159c30001063b] 00:00:06 PreventUserIdleSystemSleep named: "Address Book Source Sync"
    Timeout will fire in 1794 secs Action=TimeoutActionTurnOff
   pid 625(UserEventAgent): [0x000159c3000b063a] 00:00:06 BackgroundTask named: "com.apple.AddressBook.ScheduledSync"
    Created for PID: 62023.
   pid 526(storedownloadd): [0x000049be000112c7] 243:41:28 PreventUserIdleSystemSleep named: "URLConnection in progress"
   pid 62025(softwareupdate_notify_agent): [0x000159c3000b063d] 00:00:05 BackgroundTask named: "com.apple.softwareupdate.NotifyAgentAssertion"
   pid 79(apsd): [0x000159c80012064e] 00:00:01 InteractivePushServiceTask named: "com.apple.apsd-lastpowerassertionlinger"
    Timeout will fire in 86399 secs Action=TimeoutActionTurnOff
   pid 56(powerd): [0x000159b9000d061b] 00:00:16 InternalPreventSleep named: "com.apple.powermanagement.acwakelinger"
    Timeout will fire in 29 secs Action=TimeoutActionRelease
Kernel Assertions: 0x8=BT-HID
   id=501  level=255 0x8=BT-HID mod=01.01.70, 01:00 description=com.apple.driver.IOBluetoothHIDDriver owner=AppleHSBluetoothDevice
   id=502  level=255 0x8=BT-HID mod=01.01.70, 01:00 description=com.apple.driver.IOBluetoothHIDDriver owner=AppleBluetoothHIDKeyboard
Idle sleep preventers: IODisplayWrangler

Best Answer

A good first step towards debugging power management-related issues on OS X is:

pmset -g assertions

It can take a little practice to read the output, but it can lead to finding processes that are erroneously making power management assertions against the kernel.

It can also be an iterative process — keep running it at appropriate times, ad see what crops up!

The pmset command can do a whole lot more to control OS X power management; see the pmset(1) man page.


Edit: I have since found a way to determine if there are any processes keeping a Mac awake using only GUI tools. (Tested only on OS X 10.11):

  • First, open Activity Monitor (in /Applications/Utilities).
  • On its menu, select View → Columns → Preventing Sleep in order to display this column (which is not displayed by default).
  • You can now click on the header of the Preventing Sleep column to re-order the list of processes so that those preventing sleep are at the top.

This works in any of Activity Monitor’s five tabs, but you have to enable the Preventing Sleep column individually for each tab.