Macbook is waking up from sleep while on wifi with iMac
I have an Macbook Pro 13" 2018 as my portable/home computer and iMac in the office as workstation. When I bring the Macbook to the office and it connects to office wifi, it keeps waking up in the bag, draining the battery.
I tried to reinstall macOS, everything was ok until I signed in with my Apple ID, so I suppose it's due to handoff/continuity (only thing I have installed now is iStat menus and I'm signed to iCloud, nothing else, clean OS.)
I can lose almost full battery in one day in sleep if I don't turn off wifi and also the Macbook gets very hot and it even reboots itself because of the high temperature.
I use macOS 10.15.2 on both computers.
How can I prevent this and still have handoff/continuity enabled?
Solution 1:
Power Management is the culprit.
You should use the pmset command to see what power management has been doing. In Terminal, the basic command is
pmset -g log
But that gives you all the power management events since last boot time. You can reduce this with judicious use of grep. I have used both of these (with similar results):
pmset -g log | grep -e "Wake from" -e "DarkWake" -e "due"
pmset -g log | egrep "\b(Sleep|Wake*|DarkWake|Start)\s{2,}"
Power Management has about 20 settings that can be changed by an admin user. To view the settings (they will be different when on battery and power):
pmset -g
For my issue, which looks similar to yours, I changed the tcpkeepalive setting. With this enabled (value = 1), the MacBook will frequently wake up due to network events.
To change turn off tcpkeepalive use the Terminal command:
sudo pmset -b tcpkeepalive 0
The -b is to set for when running on battery.
I have also tweaked a few other settings like standbydelayhigh, but this is purely tweaking.
This is based on my experience with a MacBook which would lose too much (I thought) battery whilst closed overnight.
You may find these two links helpful: How to Fix macOS Mojave Battery Draining Issue and man pmset.
Note that I have not changed hibernatemode from the default value of 3. Many (including the linked article) discuss changing it to 25 which I do not recommend with recent (last 4 years) hardware and macOS version.