Beginner's Guide to Network UPS Tools (NUT) on a Raspberry Pi

Look into this post please:

1 Like

You only need one NUT server connected to a UPS. Every other Linux computer then just runs the NUT monitor as a client. It’s documented in Mel Grubb’s instructions in my original post. The instructions are for RPis, but I imagine it should be roughly the same for a NAS.

2 Likes

Thx for your hint !

Do you think if its also possible when the Raspi shutdowned by a UPS then you switch by a socketswitch (eg shelly via cloud) the Raspi OFF/ON and it starts ?
→ Socketswitch between UPS and Raspi …

Hi Stephan, that’s more or less my current setup. But I use a USB Power Supply in the socket switch to trigger the Restart circuit. The Problem with directly switching the Raspi is that you might switch it off while still running and damage the software.
For remote control you of course have to use a socket switch which is not controlled by OpenHAB… I used a remote controlled socket switch connected to my FritzBox Router, so I can restart the Raspi remotely.

1 Like

Perfect, i think i will give it a try in this way :slight_smile:

One last question:
When i have running NUT on Raspi as master and also want to switch of NAS as a slave, must be also the network on UPS for the shutdown command ?
Or is it enough to have Raspi/NAS on powersupply in UPS ?

I set it up the other way round: My NAS (QNAP) is connected to the UPS via USB and acts as NUT master. The Raspi is the slave.

Ok.
And is the Nework for your NAS and Raspi (Switch, …) also on UPS ?
Or how is the information from your NAS to Raspy during a power error ?

NAS AND Raspi are both powered by the UPS. The Network is not. So you made a point I have to consider… thanks!

@rpwong

Hi Russ,

everything works fine, thx for your Tutorial.

I only want to notice you that i had a problem by rebooting.
The NUT service dont start itself, only by my restart command by ssh.

[SOLVED] NUT Server won’t start on reboot/ Raspbian Buster/ Pi4(8GB) - Raspberry Pi Forums
This post did the trick for me, maybe other also have this problem, so you can give a hint in your initial post ?

Thank you for all
Stephan

Hello @rpwong,

thanks for the tutorial has saved me a lot of work.

Holger

Thanks for sharing this guide.
I set this up on Pi4B running openhabian, connected by USB cable to an Amazon Basics 600VA back up. At first I thought is wasn’t working based on the upsc rphs command suggested in the link under step #2. But then I tried upsc mydevicename and it listed off all of the data. So I created a Network UPS Binding Thing in the UI and it works.

openhabian@openhab:/etc/nut $ sudo upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Duplicate driver instance detected! Terminating other driver!
Using subdriver: CyberPower HID 0.4
openhabian@openhab:/etc/nut $ upsc rphs
Init SSL without certificate database
Error: Unknown UPS
openhabian@openhab:~ $ upsc openhabPi
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 20
battery.mfr.date: CPS
battery.runtime: 4125
battery.runtime.low: 300
battery.type: PbAcid
battery.voltage: 14.3
battery.voltage.nominal: 12
device.mfr: CPS
device.model: ABST600
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 15
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: CyberPower HID 0.4
driver.version.internal: 0.41
input.transfer.high: 140
input.transfer.low: 96
input.voltage: 122.0
input.voltage.nominal: 120
output.voltage: 122.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 9
ups.mfr: CPS
ups.model: ABST600
ups.productid: 0501
ups.realpower.nominal: 360
ups.status: OL
ups.test.result: No test initiated
ups.timer.shutdown: -60
ups.timer.start: 0
ups.vendorid: 0764

Not sure if the Init SSL without certificate database matters elsewhere, but for my purposes, it seems to be working just fine.

“rphs” is what Mel Grubb named his NUT server. So it would only work for you if you used the exact same name.

Ouch. That was not very bright of me. But thanks for being polite in pointing it out.

1 Like

I noticed last week the my UPS Binding thing was offline. When I check the Pi4B running openHABian which runs openHAB and NUT, there was an error that the various nut services had failed due to a file in /etc/nut/ not existing. (Unfortunately, by the time I got around to troubleshooting today the journalctl and other log files had rotated and I can’t find the actual error on the system.

I tried rebooting the Pi. Still NUT services didn’t work.
I next tried removing and reinstalling (sudo apt-get purge nut followed by sudo apt-get install nut.

After that, it worked. Not sure what the problem was. Probably something I fiddled with that I didn’t mean to. Regards, just wanted to share with future travelers on this road that my mysterious problem was solved this way.

Hmm. If a file is suddenly missing for no particular reason, your SD card might be failing. Even with ZRAM and a UPS, that can happen over time. We’re just reducing the probability of failure due to power loss.

1 Like

Thanks. I had a chance to look at it today. I rebooted (which was overkill, but I wanted clean logs). The problem I encountered was with /var/run/nut. I created /var/run/nut (mkdir nut while in /var/run) and changed ownership with sudo chown nut:nut nut/. Seems to be working. I have no idea what might have cause this. SD card is less than 6 months old. I will monitor and report back.

1 Like