The Laptop That Kept Falling Asleep

Invertedlight/ October 22, 2026/ DevOps, Home-Lab, OS X Tech Tip

“Why is the M5 offline?” So what broke? It was working while I was at home using the M5. Stepped away, Murphy snuck in, and well, you know how that goes.

Here’s the setup. The Mac mini runs a battery check script that looks after my M5 MacBook. It reads the battery level and flips a Tasmota smart plug on or off so the battery cycles between healthy limits instead of sitting at 100% forever.

The problem: the M5 was set to go to sleep after one minute on battery when the system is sitting idle. Plug turns off, laptop drifts off to sleep, the mini can’t reach it, and the plug never turns back on. Laptop napping, plug off, battery draining. Not exactly the plan.

The fix, in four parts:

  1. sudo pmset -b sleep 0. The system never sleeps on battery. The display still sleeps after 30 minutes, so the screen isn’t burning all night.
  2. Wake-on-LAN added to the mini’s script as a safety net. If the M5 doesn’t answer, it sends a magic packet, waits a few seconds, tries again, and notes “(woken by WOL)” in the report.
  3. If Wake-on-LAN (WOMP) doesn’t do the trick, the failover is to turn the smart plug back on. Plugging in power wakes the M5 right up.
  4. The cool thing about watching the battery cycling is the smart plugs. They got proper names and reserved addresses, and the report now shows watts, volts and amps. This gives me a quantitative metric on battery health and degradation.

Follow the documentation, follow your notes, and don’t let your laptop sleep on the job.

Share this Post