MacOS – My Macbook air won’t go to sleep when I close the lid

macbook promacossleep-wake

Since I have purchased my Macbookair, it has been going to sleep mode when I closed the lid and the apple logo on its lid would turn off. Randomly it started going to sleep mode after 15-30 mins later I have closed its lid and sometimes it never went to sleep. I typed "pmset -g assertions" in the terminal of my mac and these were the results:

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 117(hidd): [0x0003be5000098b76] 00:28:29 UserIsActive named: "com.apple.iohideventsystem.queue.tickle.4294995445.11" 
    Timeout will fire in 119 secs Action=TimeoutActionRelease
   pid 331(useractivityd): [0x0003c4fb00018c32] 00:00:01 PreventUserIdleSystemSleep named: "BTLEAdvertisement" 
No kernel assertions.
Idle sleep preventers: IODisplayWrangler

I didn't fully understand these results and tried several ways to solve my issue and I would very much appreciate it if someone could help me understand sleep and wake troubleshooting on the command line or from logs and settings.

Best Answer

Your output from pmset -g assertions matches mine perfectly - nothing there would prevent a quick sleep. To dig into this deeper, I like to open a command line windows/tabs and run two commands in different shells:

pmset -g pslog
iostat 5

You can change the 5 counter - I usually use iostat 60 or more to track long term CPU and IO trends, but sleep wake happens pretty quickly when things are running correctly with "out of the box" power settings and a fresh / new OS installation.

Here you can see the timing on the lid down and lid up:

2017-09-10 10:47:24 -0500 IORegisterForSystemPower: ...Sleeping...
2017-09-10 11:42:32 -0500 com.apple.system.powersources

2017-09-10 11:42:34 -0500 IORegisterForSystemPower: ...HasPoweredOn...
  Wake Reason = EC.LidOpen
  wakeType = UserActivity Assertion
2017-09-10 11:43:33 -0500 com.apple.system.powersources.timeremaining
2017-09-10 11:43:33 -0500 IOPSNotificationCreateRunLoopSource
 -InternalBattery-0 (id=4128867)    100%; discharging; 3:42 remaining present: true

Here you can see the jump in the iostat 5 where the CPU was idle entering sleep (the 4.00 1 0.00 1 1 98 being low IO, and 98 % idle CPU) for the first two lines go together. Most of the values jump up the three "intervals" when I woke the lid from sleep and the CPU kicked in gear to run all the tasks needed to wake from sleep and resume apps / catch up on periodic activities missed while sleeping)

    4.00    1  0.00   1  1 98  2.66 1.92 1.55
    4.00    0  0.00   1  1 98  2.61 1.93 1.55
   12.02    0  0.00  16 30 54  3.60 2.14 1.63
   36.18   96  3.38  59 25 16  4.51 2.36 1.71
    6.50    2  0.01  51  9 40  4.23 2.33 1.70