Turn HomeKit smart plug off upon TimeMachine backup completion

The idea is to have a HomeKit-enabled smart plug power on the backup drive at a specific time of the day and power off the smart plug once the Time Machine backup is completed.

This is where I’m at right now:

  • every day at 17:00 a HomeKit automation turns on the smart plug to power the external hard drive,
  • On mount LaunchControl runs a script that automatically backs up the drive with TimeMachine and ejects it upon completion (I can‘t code and the developer of this app actually helped me out immensely, he was extremely friendly and patient, so I can totally recommend going down this route),
  • A curl command at the end of the script triggers the automation server running on a dedicated always-on iOS device (I use an old iPhone 5s on do not disturb mode and guided access) using Pushcut,
  • Pushcut triggers a scene that turns off the smart plug.

This works like a charm and I can recommend replicating it, if you are interested and happy with the current iteration.
I do however have a couple of questions I‘d like to ask the community:

Setting up the automation server on an always-on iOS device requires a subscription to Pushcut pro, this is great and definitely does the trick; I’m happy to support this developer, but I was hoping to do this without having to depend on an external service. Any ideas?

Any thoughts/suggestions/improvement ideas regarding this project? Is there something I haven‘t considered?

If you can find the developer documentation for the smart plug you could issue the command to it directly from the command line.

If you ran HomeBridge, I’m pretty sure you could set that up to be triggered from.a script and relay it to the switch via the scene.

You have not indicated what the smart plug is delivering the power to. Is it the drive hosting Time Machine?

If that is the case, is the drive not entering sleep/standby after unmounting? That should drop the power consumption down to a very small level. The question in power saving terms would then be is the overall power consumption of the drive plus the plug (yes, smart plugs do consume a small amount of power, they are usually Linux-based computers wired into the hardware) less than the drive alone if left to go into standby?

I am actually running HomeBridge on the Mac, so if I understand it correctly this seems to be a great solution. Admittedly, I am quite clueless on how to accomplish that - I am however interested to learn if somebody could point me in the right direction. What kind of documentation am I looking for? Will I stand a chance when it comes to writing a HomeBridge plugin?

The smart plug delivers power to the external drive, that‘s correct - I apologise for not specifying that and maybe i can come up with a better subject for this thread.

That‘s a good point and great first principals thinking right there, but the main reason why I‘m doing this is noise, rather than just power consumption.
I‘m a student and my desk is located in my bedroom - the two hard drives I use for this can be noisy (both at night or whilst studying) even on standby mode.
I could transition to SSDs or maybe a more modern enclosure, but that would be expensive and besides I do enjoy the tinkering process.

If the drives are unmounted from within macOS, they should spin down soon afterwards.

In System Preferences » Energy Saver »
do you have the “put hard disks to sleep when possible” option enabled?

Thank you for your help and please excuse the poor image quality, as i‘m not currently at my desk.

This is what energy saver looks like on my M1 Mac mini.

I can hear the drives slow down once they unmount, but even then I can occasionally hear them producing sounds in an otherwise silent room.

That’s very interesting, considering that my screenshot came from an M1 Mac mini also…

I guess it’s possible that your drives don’t support that, and macOS only shows it when it senses there are drives attached that can use it?

I’m not sure what else could explain it.

:man_facepalming: The other possible explanation is that I forgot to connect the drives before taking the screenshot, please excuse me.

The option appears when the drives are connected and it is actually ticked, but as mentioned earlier I can still hear the drives make the occasional sound after being ejected.

As someone who would also be annoyed by that, I understand completely.

I think another option would be this:

it runs on your Mac, and has unique URLs you can use to trigger automations.

Jason Snell has written and talked about it:

The nice thing about its URL scheme is that even if the app is not running when you use one of the URLs, it will simply launch the app as necessary.

Definitely recommend the app, and then your “dependencies” would at least all be on the same device.

p.s. - Robby, the developer of LaunchControl, is a great guy and very helpful. Highly recommended apps: https://www.soma-zone.com. I use LaunchControl all the time, and BackupLoupe on occasion.

Thank you for your suggestion!
I had a brief look at the app and article you sent, and must admit that I’m yet to fully understand how to create a custom automation URL.
After a bit of tinkering however I was able to get it working somehow. :tada:
I’ll probably still look for some further reading material later today in order to better understand how this works.

This is a great solution and I am so very grateful.

I couldn’t be happier to have found this forum, you seem to be a cool bunch.

1 Like

Easiest way:

  1. click the HomeControl menu bar app
  2. then click Preferences (or ⌘+comma)
  3. Click the “Customize Items” button (see below)
  4. Locate the device or scene you want to automate
  5. Copy Automation URL (or assign a keyboard shortcut and use that )

Once you have the URL or the keyboard shortcut, use that in your automation.

I’m not sure there is a lot out there, but let us know if you find anything



Will at least give an overview

We’re glad you found us too! This site and the Mac Power Users forum are two of the best places I know to get Mac help/tips/tricks/etc.

This was extremely easy, it just allowed me to refine the automation a lot, now each of the two hard drives has its command.

I haven‘t come around to it yet, but I‘m sure these well be a great starting point. And I‘ll make sure to keep you posted in case I am able to find something.

Good thing that summer break is around the corner, I‘m going to have to check that out as well. :+1:

Again, thank you so much for your help!

1 Like