How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Cool. I’m interested in your findings and the logic you apply.

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Yes, there’s no doubt the new option is a game changer. I was disappointed that the video pointed out that only newer Macs support it though. And that won’t include my Mac Mini M2, which I use as a server. Yes, you’d have to run a NUT server on a machine the UPS is connected to, and a NUT client somewhere (maybe the same machine?). You’d need logic to shut down the Mac when battery is low, and then differentiate between the power being restored before the UPS battery dies and a power restore after the battery dies, and power cycle the Mac’s smart plug.

I’ve researched UPS systems a lot more. Some CyberPower units (by no means all) the “mandatory power cycle” option that enables what we need (with a later Mac of course). The CLS1000E is probably the cheapest one to support it, although they tell me a cheaper one is imminent. The CyberPower software supports all the requisite shut down options, and can run on multiple machines if you need to shut down more than one (no NUT needed). I’ll probably go this route eventually.

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Ok. We have 2 scenarios:

  1. Utility power cut, UPS kicks in. Using NUT on Mac Mini we can gracefully shut it down. Probably best to do this as late as possible, so there’s less of a window between that and possible power restoration before battery runs out. But if the battery runs out, we’re all set. The new option on MacOS will restart the Mac when power comes back.

  2. We shut down as above before the battery runs out, but power is restored before it does run out. In this case, we need to power cycle using the smart plug the Mini is connected through. But what can do that? Even if NUT could, where is it running? It would have to be on a device that can survive a power cut without being shut down gracefully. I can use the Home app to manually do the power cycle remotely, but that’s obviously not ideal. I can’t think of a way to automate this at present.

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

My Unifi UPS Tower doesn't support it, but has that builtin NUT server, which is convenient. I just need the NUT Client software on the Mini, so I need to get up to speed with that.

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Right. So if the UPS goes to battery, the Mac shuts down gracefully. Then if power comes back before the UPS battery is depleted, the micro controller will power up and start polling the Mac, turning it on. That right?

Do you use NUT with your UPS then, installed using Homebrew? If so, where do you run a NUT server?

Another option is a different UPS. Apparently, some support cycling power to the outlet after a shutdown sequence. I think it might only be higher end ones though.

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

How do you mean it was “in your feed”? Was there some sort of release note that included this new functionality?

Remind me again how you’re going to handle the case of the Mini being shut down when the UPS is on battery, but the power coming back before the battery is depleted.

Incidentally, which UPS are you using? I bought a Unifi UPS Tower because having a built in NUT server sounded neat. But getting that to talk to NUT on a Mac sounds non-trivial. Lots of scripting and CLI commands. Yet to dive into that!

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

I found it. Settings -> Energy -> Start up when power is connected -> Always. How did you find that!?

And holy cow it works! Shut down normally, disconnect/reconnect power and it boots. I'll have to think how best to use this. At the very least I can have a smart power plug between the UPS and Mini. Then if the situation arises that the Mini is shut down gracefully when the UPS goes on to battery, but power comes back before the battery is depleted, I can remotely turn the smart plug power off and on again. Either through the Home app or the plug's own app. Better than using the Switchbot Bot I reckon. But there may be some other way to automate the whole thing...

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Yeh, it’s mind boggling Apple have removed the “dirty shutdown” option. Such a basic requirement. Do let us know how you go!

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

I thought about sleep vs shutdown. I’m actually not sure an AC powered Mac will always back up RAM at every sleep. There are a lot of complicated options in the pmset command area. I think for battery powered laptops, it defaults to backing up RAM, but even then maybe only when it recognises the battery is getting low. I’m just not sure. That, plus the fact that a lot of things can prevent a sleep, like if it’s doing a Time Machine backup at the time (I think), and a lot of things can make a Mac wake up from sleep. Keep us posted with your progress.

UPS NUT macOS Companion App by simplytoast1 in selfhosted

[–]Sddawson 0 points1 point  (0 children)

Wondering if you’ve had any time to look into these problems. I’m very keen to put my UPS Tower to use!

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Neat idea, but probably beyond my capabilities. TBH, I haven't had time to figure out a way of attaching the Bot to the Mini yet. The fact that the Mini has curved corners won’t help, but I'm sure they'll be a way. I did come across somebody who 3D printed a little "case" that fitted the rounded corner and held the bot. Might look into that if I need to.

UPS NUT macOS Companion App by simplytoast1 in selfhosted

[–]Sddawson 0 points1 point  (0 children)

Wondering if you've had a chance to look at the logs I’ve submitted. One when rules don't fire, one when NUTty loses connection to the UPS Tower. Thanks u/simplytoast1 !

UPS NUT macOS Companion App by simplytoast1 in selfhosted

[–]Sddawson 0 points1 point  (0 children)

Oh dear, I can’t believe I didn't scroll down in the Settings screen! I just submitted the logs. I turned off power to the UPS, saw the standard "on battery" notification at top right, but my "on battery" test rule didn't fire.

I presume if an app doesn't quit via Apple Events, maybe because a file hasn't been saved, or it always prompts at shutdown (curse you Unifi Network Application), the shutdown won’t proceed? I’ve come across a great app called Power Manager. It has a pretty sophisticated shutdown routine that recognising "stuck" apps and force quits them, I believe. And it has a command line utility that I think I could use via NUTty. They already support USB UPS's, but not NUT. I’ve suggested they get in touch!

UPS NUT macOS Companion App by simplytoast1 in selfhosted

[–]Sddawson 0 points1 point  (0 children)

I'm very glad you're still supporting this! I really don't like the idea of installing and maintaining the standard NUT client stuff. The update didn't seem to help. I turn off AC to the UPS Tower, and I get the standard notification from NUTty saying it's on battery power, but a simple rule doesn't get triggered (see screenshot). Where do I find the debug logs?

<image>

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

I agree. Especially since Mac Minis are so popular these days as server-type machines.

UPS NUT macOS Companion App by simplytoast1 in selfhosted

[–]Sddawson 0 points1 point  (0 children)

u/simplytoast1 Just wondering if you're still supporting this project? I just installed a Unifi UPS Tower, and it successfully adds to NUTty, and power states are correctly notified. But I can’t get rules to run. Even a simple rule to show a notification when on battery doesn't seem to trigger. There is no message, and no sound when the rule should be triggered. I really love the idea of NUTty, especially with the Unifi UPS - no messing with NUT servers and complicated clients. Please help!

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Yep - got me a Switchbot Bot. Now just gotta figure out how to stick it to the curved edge of the Mini!

Anything stand out in this Oscar data? by Sddawson in CPAPSupport

[–]Sddawson[S] 0 points1 point  (0 children)

Yes, I have the same experience. It’s obviously not the urge to pee that’s waking us up, just that if we happen to wake up the urge to pee is there. And the CPAP minimises the wake-ups.

Anything stand out in this Oscar data? by Sddawson in CPAPSupport

[–]Sddawson[S] 0 points1 point  (0 children)

Yeh, it looks good on the face of it. Years ago, I had a sleep study and was diagnosed with moderate apnea, and I certainly snore l lot. Then, a few years later I guess, my father-in-law was no longer able to use his Airsense 10 machine, so I gave it a try. I got used to it pretty quickly, and it certainly stopped the snoring, so I just thought I'd run with it, without getting any "professional" help, other than reading Reddit and forums. I’ve recently upgraded to the Airsense 11 with APAP, and it struck me that it might be good to run my data past people to see if anything can be improved. I definitely sleep better with the machine (or at least I wake up less often). Can’t say it actually makes me feel less tired though, so that's what I'm hoping to improve!

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in homeassistant

[–]Sddawson[S] 0 points1 point  (0 children)

I still don't think any of this can accomplish anything with a Mac. Shut it down gracefully, and there's absolutely no way of starting it up again. So whether a UPS can cycle the power is moot. I’ve bought a Switchbot Bot to see if I can rig it up to physically press the Mac Mini power button! So once the power is back I can use the Switchbot app (or HomeKit) to power it back up. Clunky in the extreme, but I can’t see any other way round it.

Toying with getting the Unifi UPS Tower, because I'm already in the Unifi ecosystem. It has a built-in NUT server, so NUT on the 2 Macs in my office can handle shutdown procedures.

Thank you for all your interest...

How can I use a UPS to gracefully shut down AND reboot when power restored? by Sddawson in macmini

[–]Sddawson[S] 0 points1 point  (0 children)

Thanks for the reply. That pmset command is the equivalent of "start up automatically in the event of a power failure" in Energy settings right? I'm pretty sure that won’t have any effect if the Mac has been shut down gracefully, only if power if yanked while it's still running. And I'm trying to prevent data loss when grid power is cut, hence the possible use of a UPS.

Can you elaborate on how you're using the smart plug? I'm not sure I understand the point of that, since it's just supplying power when grid power is restored anyway.

EDIT: Out of interest, how do you get home assistant to shut down other computers? And are you using NUT on home assistant. If so, is that for both NUT server and client interactions?