Auto Run HomeKit Automation when waking from sleep OSX

My new Mac mini M4 pretty well insists that I must use the sleep command instead of powering down.


Apart from the computer, I use quite a few power hungry peripherals when I’m using the computer. With my old iMac setup I had a switch which sensed the presence of USB power and then automatically switched those peripherals on and off whenever the computer was powered up and down. That is no longer possible as the USB ports remain powered during sleep.


On the new setup I’m using a HomeKit smart socket to control the peripheral devices. HomeKit allows me to create a script so that the computer can shut things down in an orderly fashion and then after a pause to let everything become safe, go into sleep mode.


I can’t see a way to trigger a HomeKit automation or Shortcut when it wakes from sleep. At the moment I have to manually run a Shortcut to do that. Is there a way to make this happen automatically?


It seems odd that HomeKit / Shortcut will let me script an operation to Sleep my Mac, but doesn’t appear to offer an option to trigger a script when it wakes from sleep.

Mac mini, macOS 15.1

Posted on Dec 16, 2024 08:31 AM

Reply
3 replies

Dec 17, 2024 08:16 AM in response to hcsitas

My query was not so much to do with the Mac itself, but how to automatically power down all the peripheral equipment when the Mac mini isn’t being used. Some of it is computer equipment, but most of the power is consumed by A/V equipment which I use with the computer.


The Mac and the monitor pretty well look after themselves in that respect, going dormant when not in use for a while. The problem I’m trying to solve is how to automatically power down all the peripherals and fire them up again. The Mac is generally used quite intensively when it’s being used, but is often left unused for several days at a time.


My previous solution was a USB controlled switch. My old iMac was switched on and off as required and everything else followed suit. It worked brilliantly for many years. Sometimes I left the iMac on overnight for housekeeping tasks, but manually disabled the peripherals.


The power switch on my Mac mini is pretty well inaccessible because the Mac mini lives on a shelf with other stuff above it. Even when put on a desk, it’s awkward to use that switch. It was clearly intended not to be operated under normal circumstances.


I bought a slave socket, but it proved to be unreliable, triggering at odd times, presumably when the Mac was housekeeping. I also tried using the slave socket triggered by the monitor instead, but the standby current seems to be above the threshold to trigger the slave sockets. A HomeKit smart switch could be a possible solution, but only if I can make it trigger according to the operational state of the Mac mini. It would also allow me to automate other aspects of my office, such as smart task lights coming on if the Mac is being used after dark, or disabling the sound of my doorbell and flashing lights instead if I’m working on an audio project.


I’ve got HomeKit automating quite a lot of stuff, but I haven’t found a way for HomeKit or Shortcuts to react according to whether my Mac mini is being used or not.

Dec 17, 2024 04:19 AM in response to Alän

It does nothing of the sort. Sleep is unnecessary on later Macs and should be disabled. Shut for long absences/idle overnights and for regular operation, use the settings exactly as shown below:



Also, do not manual-sleep for brief absences, let the Lock Screen settings switch the display off on timer:



Once set, you can also use Control-Command-Q to lock your screen immediately.

Dec 17, 2024 08:35 AM in response to Alän

“My new Mac mini M4 pretty well insists that I must use the sleep command instead of powering down.”


That is incorrect - don’t need to do either: you can keep your Mac on without sleeping or shutting. The only power hog in a running-but-doing-nothing Mac is the display which can be set to turn off on timer and/or locked by command.


Sleep is the worst option of the three - it not just consumes more power, it also throws out mystery issues. Unless you like such challenges, disable Sleep as shown and shut for long absences (whatever that means for you, can also mean never). It’ll solve all your issues in one shot with no compromises whatsoever.


All the best!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Auto Run HomeKit Automation when waking from sleep OSX

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.