UPS shutdown of NUC

With my Roon NUC connected to a UPS unit, is it possible to have the NUC auto-shutdown with a USB cable connected to the UPS when the battery gets too low during a power outage? I have this option with my Mac and Synology NAS. I’m assuming the answer is ‘no’ because the OS would need to support it (?), but curious what options there are to try and do this somehow? I’m having power outages here the past few days and my NUC abruptly shuts off once the UPS battery has been exhausted (trying to prevent damage to it if I can). Thanks for any tips!

1 Like

As long as your NUC is running Linux or Windows. Such ability is not included in ROCK, which is why I posted it as a requested update for a ROCK 2.0 in that thread.

3 Likes

The only workaround with ROCK is to have another device, e.g., Raspberry Pi running Linux, manage the UPS, and to initiate ROCK shutdown via a shutdown script:

# Power off Roon server
$ curl http://rock.local/1/poweroff &
3 Likes

Thanks @Martin_Webster - I do have a spare RPi not in use (DietPi OS), so this would be a good use for it. Looks like I have some learning to do! :upside_down_face:

1 Like

I use apcupsd with my UPS; if this supports your UPS, I can give you some pointers.

1 Like

Great - thank you for the offer! All my UPS units are CyberPower (this one being EC450G that it’s connected to). Looks like you may use APC, but hopefully similar type of setup with CyberPower’s software (and similar scripting). First thing I gotta do is learn how to get Linux onto RPi - I’ve only messed with it one time a few years ago for the sole person of running Roon extensions (which I now run on my Synology in Docker).

I can’t believe all the UPS chirpings here at my place these past few days with the brownouts going on (heatwave). I can’t even run my main computer the entire day because of it. We recently had “smartmeters” installed in my neighborhood and I now have these electrical problems. It was never this bad pre-smartmeters, so they have actually downgraded my electrical service (it’s gotta be the smartmeters to blame I would think - it’s the only change).

No, it’s another brand, but supported by apcupsd. CyberPower should work fine with this, too. Have a look at this tutorial.

https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#1-overview

To install UPS support, this should get you there …

sudo apt install apcupsd
sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.bak

# Configure for USB: change UPSNAME, e.g., CyberPower EC450G
sudo nano /etc/apcupsd/apcupsd.conf

    UPSTYPE usb
    DEVICE
    POLLTIME 60
    LOCKFILE /var/lock
    SCRIPTDIR /etc/apcupsd
    PWRFAILDIR /etc/apcupsd
    NOLOGINDIR /etc
    ONBATTERYDELAY 6
    BATTERYLEVEL 50
    MINUTES 10
    TIMEOUT 300
    ANNOY 300
    ANNOYDELAY 60
    NOLOGON disable
    KILLDELAY 0 
    NETSERVER on
    NISIP 127.0.0.1
    NISPORT 3551
    EVENTSFILE /var/log/apcupsd.events
    EVENTSFILEMAX 10
    UPSCLASS standalone
    UPSMODE disable 
    STATTIME 300
    STATFILE /var/log/apcupsd.status
    LOGSTATS off
    DATATIME 0

sudo nano /etc/default/apcupsd

    ISCONFIGURED=yes

sudo systemctl restart apcupsd

# If all is well, this will query the UPS and give battery status etc.
apcaccess

You’ll then need to open the shutdown script, and add the line I posted earlier.

2 Likes

Thank you so much for the additional information! This definitely helps to get me started. Much appreciated!

You can set the BIOS of the NUC to “restart on power resumption” if the UPS really runs out. While not really advisable , I have run my NUC with no UPS on this feature during our 2-3 x a day outages. Fortunately they seem to have stopped now.

Also don’t forget that running a normal deep cycle lead acid battery to high DOD (Depth of Discharge) really screws the longevity of the battery . The Li Ion ones should stop at 80% DOD but lead acid maybe 50 - 60% High discharge will cost you in the quite short term.

We bought a 2 x 12 V UPS to run essential stuff (TV , Hi Fi , Router etc) during power outages only to find the batteries died after 3 Months !! At first we got 4hrs TV , dwindling to 30 mins OUCH

There are many UPS experts in South Africa :smiling_imp:

1 Like

Ah … good to know that option exists! My NUC went down multiple times yesterday and today because of brownouts/low voltage issue (the UPS just could not keep up), and I finally gave up and just left it off (which made me sad) because I didn’t want to ruin the NUC. Not sure how robust these machines are to handle this kind of electrical abuse.

Interesting info on deep cycles (need to learn :upside_down_face: ) - 2 of my UPS units kept getting fully drained and the longevity of my main one (connected to mac mini) is so short now (so that battery must be bad inside of it and it’s not that old of a unit). My poor mac kept forcing power off the past few days as well (like my NUC) because the mac was not honoring the UPS power shutdown settings in the OS (Ventura). I kept trying different settings to get it to work and nothing would honor it, so that’s another problem I have to troubleshoot (looking online at forums isn’t promising that this is actually fixed).

I’m well aware of the ‘challenging’ electrical issues in your beautiful country :grimacing: You certainly need to be an expert on UPS’s to keep your equipment alive.

The settings I shared, are set at 10 minutes or 50% discharge prior to initiating shutdown.

It’s actually the system disk potentially getting corrupted by intermittent power cuts during write cycles.
The hardware itself should easily handle the power cycling.

If you’re connecting many power hungry devices to your UPS you just need to scale it’s capacity correspondingly to be able to survive the given conditions…

1 Like

I purposely don’t do this. I want to know when my Core has had an outage.

If so, upon return of power I do a Restore without a second thought. Better that than getting hit with latent corruption of the database, somewhere down the road.

1 Like

This should be standard procedure for everyone. As should having a “known good” or verified backup.

And therein lies the problem. How does one verify a Backup, except by doing a Restore that might fail and potentially corrupt the database in the bargain? Kind of begs the question.

If Roon keeps having trouble with bad Backups, maybe it would be in everyone’s interest to supply a procedure where a Backup could be checked without having to chance an actual Restore. The code already exists, in principal.

1 Like

You restore to a test PC, which is what I do.

1 Like

That’s a good idea and I do have a spare ROCK that I’m using as an endpoint. Not sure how many people are in a similar situation as far as an extra Core goes, but it works for me. :slightly_smiling_face:

That’s an interesting idea - my Synology (DS1621+) stayed up almost the entire time these past few days (while everything else was failing all around me). Is it a good idea to host a secondary Core on Synology? It already has a full copy of my music (for Plex purposes). That could be a handy backup solution.

If you’re asking me, I don’t know how Core runs on a Synology.

As a test bed to test the viability of a Backup, it seems like it would work as long as the original database isn’t overlaid by a second Core. Strictly as a backup to Core, then not so much as it is on the same physical device as your primary Core.

1 Like

My situation is very abnormal. Our power utility (Eskom) until recently simply couldn’t generate enough power to meet demands . By a VERY wide margin . It seems to have miraculously improved recently ???.

Up until a month ago we we getting “Load Shedding” , i.e. pre-planned blackouts of 2.5 hrs by area sometimes 3 times a day.

Each return of power meant groveling (or move the NUC) to restart the NUC so I made the executive decision to have the NUC restart automatically . The only drawback is that the network boots slower than the NUC so the Tidal connection fails and has to be made manually. Roon starts normally even with no Internet Connection at that stage.

I agree in an instance where it fails I would also like to know why BUT I do !!

I appreciate the risk and so far I have seen no ill effects. My 2 windows PC are manually shutdown prior to a power cut , I believe Windows is far more sensitive to being shut off . They are on a UPS so that is controlled.

The situation has improved so it’s no longer a problem. Dare I be cynical , 2024 is an election year :smiling_imp: