Since a while I experienced several Apple sleep issues, random wake ups and unexplainable battery drains.
What I did to solve this issues was :
1. Turned off Screen Time
Go to system Preferences -> Screen Time and turn it off.
2. Changed the Notifications settings
Go to system Preferences -> Notifications.
3. Changed Bluetooth wake up
Go to system Preferences -> Bluetooth -> Advanced.
4. Disabled PowerNap
Battery preferences. More info about powernap can be found here : More info about power nap : https://support.apple.com/en-gb/HT204032
5. Turned off proximitywake.
Proximitywake is a feature where nearby apple devices are able to communicate with your mac regardless its powerstate.
I disabled this option so set this to 0.
sudo pmset -a proximitywake 0
Other settings | sudo pmset -a ttyskeepawake 0 sudo pmset -a tcpkeepalive 0 sudo pmset -a proximitywake 0 sudo pmset -a standby 0 sudo pmset -a autopoweroffdelay 0 sudo pmset -a womp 0 sudo pmset -a ring 0 sudo pmset -a networkoversleep 0 sudo pmset -a hibernatemode 25 sudo pmset -a destroyfvkeyonstandby 1 |
If you see ‘Dark Wake’ in the logs. This one is related to software automatic software updates performed by apple while the Mac is not being used. |
6. App Nap prevents MacBook to sleep
With the following command I found that an app prevented the Macbook to sleep.
pmset -g assertions
pid 369(SecureCRT): [0x00000038000181c1] 00:13:36 PreventUserIdleSystemSleep named: “Disable App Nap per User Request”
App Nap is a power saving feature which was released in Mac OS X 10.9 Mavericks.
This feature puts helps saving power by putting applications to sleep who are inactive in the background.
If this setting is enabled for a certain application then this will prevent the MacBook to go to sleep.
You can turn off or on App Nap for individual applications.
Go the application in Finder -> Right-click on theapplication -> Get Info.
Now check or uncheck the option “Prevent App Nap.”
More info on : https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/AppNap.html
7. Check power events.
You may check the Power Events via the Apple Menu.
Apple menu -> About this Mac -> system report – > Hardware, Power. This wil list the next scheduled wake-ups including Reminders, weekly report
8. Use command line to troubleshoot
I used the commands pmset -g and pmset -g log to troubleshoot the wakes.
one easy way to see if you iMac slept is to use this command : pmset -g log
pmset -g log | grep ‘Total Sleep/Wakes since boot’
Total Sleep/Wakes since boot at 2020-04-05 19:01:41 +0200 :35
here this computer sleep/wakes 35 times since its last boot.
pmset -g log | grep -w –color -e ‘Entering Sleep’ -e ‘Wake Requests’ -e ‘Client Acks’
This display the sleep/wake sequences.
the sequence is
- Entering Sleep
- Wake Requests, this list all the future wake and who request it and when
- PM Client Acks, got do sleep
- Kernel Client Acks, kernel wake the computer due to the earliest wake Request
2020-04-26 20:30:17 +0200 Wake Requests [*process=mDNSResponder request=Maintenance deltaSecs=7200 wakeAt=2020-04-26 22:30:17] [process=powerd request=AdaptiveWake deltaSecs=41383 wakeAt=2020-04-27 08:00:00] [process=powerd request=TCPKATurnOff deltaSecs=28000 wakeAt=2020-04-27 04:16:57] [process=powerd request=UserWake deltaSecs=18763 wakeAt=2020-04-27 01:43:00 info=”com.apple.alarm.user-visible-Weekly Usage Report,364″]
2020-05-31 10:00:14 +0200 Wake Requests [*process=powerd request=AdaptiveWake deltaSecs=82790 wakeAt=2020-06-01 09:00:04]
2020-05-27 23:33:06 +0200 Wake Requests [*process=powerd request=TCPKATurnOff deltaSecs=43255 wakeAt=2020-05-28 11:34:01]
More info about power nap : https://support.apple.com/en-gb/HT204032
pmset -g assertions
This is a list with things that keep you make awake. The 1 shows its active a zero means the setting is not active.
Pmset -g live displays the power settings currently in use
Scheduled events
pmset -g sched will show you scheduled events
pmset schedule cancel wake “09/02/08 00:00:00” will cancel an event
pmset: Error in scheduling operation
sudo pmset schedule cancelall
sleep 1 (sleep prevented by SecureCRT, sharingd)
Try opening up Activity Monitor, setting it to view All Processes, and then in the list of processes, right/control click on the header and turn on “Preventing sleep”. This may show something useful. |
TCPKeepAliveDuringSleep
Running the belowcommand turns out that there is an exact time set of 43200 seconds which is exactly 12 hour. The MAC wakes every 2 hours and stops with this behavior after 12 hours.
ioreg -l | grep IOPlatformFeatureDefaults
Turn off TCPKeepalive : sudo pmset -b tcpkeepalive 0
Standbydelaylow, standbydelayhigh and highstandbythreshold
standbydelaylow default is 10800, it takes 3 hours to go into standby mode.
standbydelayhigh default is 86400 (24 hours) and the battery charge was high enough (this controlled by the highstandbythreshold parameter of pmset.
highstandbythreshold this parameter controls setting of the highstandbytreshold battery charge.
default it is set to 50, so 50% charge. So above this treshold of 50% the MAC waits for 24 hours before going into standby mode.
Setting both standbydelaylow and standbydelayhigh to the same value solves the problem.
(Sudo) pmset -a standbydelaylow 3600 and
(sudo) pmset -a standbydelayhigh 3600, replacing 3600 by the desired time in seconds.
PM Set command in general
pmset — manipulate power management settings | |
Description | pmset manages power management settings such as idle sleep timing, wake on administrative access, automatic restart on power loss, etc.Note that processes may dynamically override these power management settings by using I/O Kit power assertions. Whenever processes override any system power settings, pmset will list those processes and their power assertions in −g and −g assertions. See caffeinate(8). |
Setting | pmset can modify the values of any of the power management settings defined below. You may specify one or more setting & value pairs on the command-line invocation of pmset. The −a, −b, −c, −u flags determine whether the settings apply to battery ( −b ), charger (wall power) ( −c ), UPS ( −u) or all ( −a ).Use a minutes argument of 0 to set the idle time to never for sleep disksleep and displaysleeppmset must be run as root in order to modify any settings. |
Synopsis | pmset [−a | −b | −c | −u] [setting value] […] pmset −u [haltlevel percent] [haltafter minutes] [haltremain minutes] pmset −g [option] pmset schedule [cancel | cancelall] type date+time [owner] pmset repeat cancel pmset repeat type weekdays time pmset relative [wake | poweron] seconds pmset [touch | sleepnow | displaysleepnow | boot] |
Settings | displaysleep – display sleep timer; replaces ’dim’ argument in 10.4 (value in minutes, or 0 to disable) disksleep – disk spindown timer; replaces ’spindown’ argument in 10.4 (value in minutes, or 0 to disable) sleep – system sleep timer (value in minutes, or 0 to disable) womp – wake on ethernet magic packet (value = 0/1). Same as “Wake for network access” in the Energy Saver preferences. ring – wake on modem ring (value = 0/1) powernap – enable/disable Power Nap on supported machines (value = 0/1) proximitywake – On supported systems, this option controls system wake from sleep based on proximity of devices using same iCloud id. (value = 0/1) autorestart – automatic restart on power loss (value = 0/1) lidwake – wake the machine when the laptop lid (or clamshell) is opened (value = 0/1) acwake – wake the machine when power source (AC/battery) is changed (value = 0/1) lessbright – slightly turn down display brightness when switching to this power source (value = 0/1) halfdim – display sleep will use an intermediate half-brightness state between full brightness and fully off (value = 0/1) sms – use Sudden Motion Sensor to park disk heads on sudden changes in G force (value = 0/1) hibernatemode – change hibernation mode. Please use caution. (value = integer) hibernatefile – change hibernation image file location. Image may only be located on the root volume. Please use caution. (value = path) ttyskeepawake – prevent idle system sleep when any tty (e.g. remote login session) is ’active’. A tty is ’inactive’ only when its idle time exceeds the system sleep timer. (value = 0/1) networkoversleep – this setting affects how OS X networking presents shared network services during system sleep. This setting is not used by all platforms; changing its value is unsupported. destroyfvkeyonstandby – Destroy File Vault Key when going to standby mode. By default File vault keys are retained even when system goes to standby. If the keys are destroyed, user will be prompted to enter the password while coming out of standby mode.(value: 1 – Destroy, 0 – Retain) |
−g (with no argument) will display the settings currently in use. −g live displays the settings currently in use. −g custom displays custom settings for all power sources. −g cap displays which power management features the machine supports. −g sched displays scheduled startup/wake and shutdown/sleep events. −g ups displays UPS emergency thresholds. −g ps / batt displays status of batteries and UPSs. −g pslog displays an ongoing log of power source (battery and UPS) state. −g rawlog displays an ongoing log of battery state as read directly from battery. −g therm shows thermal conditions that affect CPU speed. Not available on all platforms. −g thermlog shows a log of thermal notifications that affect CPU speed. Not available on all platforms. −g assertions displays a summary of power assertions. Assertions may prevent system sleep or display sleep. Available 10.6 and later. −g assertionslog shows a log of assertion creations and releases. Available 10.6 and later. −g sysload displays the “system load advisory” – a summary of system activity available from the IOGetSystemLoadAdvisory API. Available 10.6 and later. −g sysloadlog displays an ongoing log of lives changes to the system load advisory. Available 10.6 and later. −g ac / adapter will display details about an attached AC power adapter. Only supported for MacBook and MacBook Pro. −g log displays a history of sleeps, wakes, and other power management events. This log is for admin & debugging purposes. −g uuid displays the currently active sleep/wake UUID; used within OS X to correlate sleep/wake activity within one sleep cycle. history −g uuidlog displays the currently active sleep/wake UUID, and prints a new UUID as they’re set by the system. −g history is a debugging tool. Prints a timeline of system sleeplwake UUIDs, when enabled with boot-arg io=0x3000000. −g historydetailed Prints driver-level timings for a sleep/wake. Pass a UUID as an argument. −g powerstate [class names] Prints the current power states for I/O Kit drivers. Caller may provide one or more I/O Kit class names (separated by spaces) as an argument. If no classes are provided, it will print all drivers’ power states. −g powerstatelog [-i interval] [class names] Periodically prints the power state residency times for some drivers. Caller may provide one or more I/O Kit class names (separated by spaces). If no classes are provided, it will log the IOPower plane’s root registry entry. Caller may specify a polling interval, in seconds with -i <polling interval>; otherwise it defaults to 5 seconds. −g stats Prints the counts for number sleeps and wakes system has gone thru since boot. −g systemstate Prints the current power state of the system and available capabilites. −g everything Prints output from every argument under the GETTING header. This is useful for quickly collecting all the output that pmset provides. Available in 10.8. | |