How to wake Mac for Automation

Install and trigger Amphetamine programmatically as user to be done with Caffeinate?

See one of the answers In this old Stack Exchange thread for the premise.

Amphetamine supports AppleScript, and you can call AppleScript at the command line with osascript. That’s what I would explore to see if I could force wake the display along with the device.

Did you try and resolve this subsequent issue yourself in any way?

I’ve tried the wake action in Keyboard Maestro and I’ve tried the Power Manager which I know works but costs an annual subscription.

Yes, you can schedule your Mac to wake up at a specific time without relying on third-party apps. Apple’s built-in “Energy Saver” settings allow you to do this. Here’s how:

  1. Go to System Preferences: Click on the Apple logo in the top-left corner of your screen and select “System Preferences.”
  2. Energy Saver: In System Preferences, click on “Energy Saver.”
  3. Schedule: In the Energy Saver window, click the “Schedule” button in the bottom-right corner.
  4. Set Wake and Sleep Times: Check the box next to “Start up or wake” and then configure the time you want your Mac to wake up. You can set it to wake daily, on specific days, or just once.
  5. Save: Click “OK” or “Save” to apply the schedule.

Your Mac will now wake up at the specified time. This is a convenient way to run automation or other tasks without the need for third-party apps.

While it is absolutely a valid way to power on your Mac, do take note that pmset, as suggested above, provides a superset of this and allows for more flexible control with regards to automation.

What is the syntax for creating a link box like the one above? It would be very useful to know.

There is no syntax. It is just posting a raw URL. If the forum can retrieve the details to display a card view, it will. I assume it is basing it on the availability of Open graph data.

Going back to the original thread, did Amphetamine in combination with pmset do everything you then needed, or did you come across any further issues? You noted other things you previously tried, but no update on the offered solution.

No, I’ve tried pmset and Power Manager but the Mac still doesn’t stay awake long enough to run any automations.

It’s the weirdest thing, the Mac wakes up right at 8am and a few seconds later the screen turns off a few seconds later. and Bunch doesn’t run.

You said earlier you know that using Power Manager works, so presumably something has changed since then.

I would still recommend try using Amphetamine (free) and pmset (default in OS) as an equivalent combo seems to have worked for others in the past (see links above), and it seems to be something you have not tried.

You should also check you don’t have something immediately sending your Mac’s screen back to sleep. If you do, it may be nothing may work, or that results are variable.

I’ve reset Amphetamine and will try again.

Same result. Without user interaction, the screen turned on for a few seconds and then went back to sleep. Also, none of the automations launched automatically; they needed user input. I can only assume that’s because the screen was off, and I know that no modern automation applications can wake a Mac yet. I don’t know how to solve this issue. I need help from the Automators.

Like I said above. That sounds like you have something overriding the normal behaviour. The wake ups are working, but it seems like something else is forcing it back to sleep.

Maybe try an SMC reset. See if that changes the behaviour.

I thought you can’t reset the SMC, because the M1/2 Mac doesn’t have a System
Management Controller. You can’t manually reset the NVRAM / PRAM because
the Mac does this automatically, if needed, during every startup. At least that’s what I read. If this is incorrect, can you give me the key combination for an SMC reset?

https://discussions.apple.com/thread/252114787

Apple Silicon Macs do a reset on startup. You hadn’t shared what type of Mac you had, so I was making a suggestion based purely on the behaviour - SMC resets (on Intel) have commonly resolved power issues, which could have been a reason for the Mac entering sleep so quickly after a wake instruction.

You have to accept we are working a little blind here in trying to help your resolve this.

Based on what you have shared, and as I noted above, it sounds like something is triggering the sleep again - counter to the usual issue of Macs waking shortly after bing put to sleep.

My earlier suggestion was to investigate this avenue, so in your position I would have also been trying this without any external hardware other than a PSU connected, looking at what is set up in any scheduled or triggered automation utilities (including at the command line), reviewing system console logs to see if there is a message logged about an event that sent th Mac back to sleep, etc.

If you haven’t tried any of that, I thibk it would be a next reasonable step to do so.

  1. My Mac is an M2 Max Mac Studio.
  2. I only have one wake up time setup.

CleanShot 2024-01-03 at 09.29.28

  1. My Bunch automation did launch.
  2. The monitor still went back to sleep a few seconds after the wake up at 07:59:00.
  3. Could the issue be with the monitor itself?

As already noted, you want to eliminate any potential issues pertaining to external hardware, and a monitor is external hardware for any headless computer.

I think the question should be do you have another monitor you could try with to rule it in/out?

  1. No, my apologies; unplugging the one external hard drive plugged in and then trying to wake it up is the one thing I have not tried yet. I’ll do that next.
  2. No, I don’t have an additional monitor to test with until I purchase an Apple Studio Display.

I do want to know is anyone else running automations that they don’t want user interaction for?

Hello @bocciaman :wave:

Regardless of what issues might still persist as of today and the fact that Power Manager has an annual subscription model …

  • it’s packed with a lot of features for automation

  • it is the only kind of software that is able to unlock your Mac for doing what it is supposed to do (what is actually one of the best features of all this Application has to offer). Because of this feature you can let all your Macs do what ever they are set up to do without your interaction and you are able to keep your Mac security as high as possible….

while pmset has great options for waking up your Mac and all the other things you can do with it - it is not able to log you automatically into your User Account…

Every thing that could be done without visual dependency is possible if you’re able to script it and combine it with launchagents and or Keyboard Maestro, Automator, EventScripts or other automation tools.

But when it comes to automations which use images as a base you would have to be logged into your account… maybe you can create something that is able to detect when your Mac is not at sleep anymore and logging you in … but this will cost you parts of your Mac‘s security… and here comes another great feature to play if you have PowerManager … it is even able to lock you in when your Mac was booted up from shutdown and manage your automations. I don’t know if that is even possible without PowerManager. Maybe not…

Greetings from Germany

Tobias

1 Like

It also has a non-subscription option:

1 Like

Hello @MevetS :wave:

Thanks for reminding me on the existence of this article… I totally forgot about that this exists…

Greetings from Germany

Tobias

1 Like