APC UPS Multiple shutdown using NUT

Hi everyone

this is not OH related but I thought I would post here as there are some smart people here amd some may have experienced the same thing.

I have just brought an APC UPS the Back-UPS 700 it has a powerchute USB connector

I’m wondering if anyone knows how too connect this too more than one pc for Shutdown

I have found (NUT) Network ups tools

Is it possible too run something like that on a rpi or other device and then add the different machine needing shutdown too that

Any advice or pointers appreciated

Devices needing shutdown

Windows 10 Machine
Readynas 104
RPI running OH

I was reading some documentation on the READYNAS it says you can connect a ups and it uses (nut) and you can connect other devices too that

I use NUT to shutdown all my VMs. I have an old RPi 1 plugged into the UPS USB and run NUT server on that. I didn’t want to run the NUT server in a VM because I have the hypervisor configured to shutdown too and that would fail if the server gets shutdown before the hypervisor, as would necessarily be the case if I ran it on a VM. On all the other VMs and machines connected to the UPS for power I run NUT in client configuration.

I set this up months ago and I no longer have reference to the tutorial I followed.

This one looks close, though it is a little old:


I’ve not fully tested the shutdown feature yet but I lost power for a couple of hours last week and everything kept running. I didn’t get an alert like I expected though. Clearly I need to go back and spend some time testing it to failure and figure out why I didn’t get my email alerts (duh, I also had an internet outage from my ISP at the same time, that’s why I didn’t get my email and OH alerts! [smacks head]). When power and internet came back I was able to see the battery level went down in OH, so at least that part worked. :slight_smile:

I’ve no experience with running it on Windows. I would expect the NAS to work similar to how it worked in ESXi. I just had to install the plug-in and point it at the NUT server.

I’m not sure I helped much but maybe I gave you enough to start searching for tutorials.

If I were you, I would set up your Readynas as the NUT server, if it is possible though. You probably want that to be the last thing that shuts itself down. That is one of the key distinctions between the server and the clients. The server/master waits for the slaves to shutdown (or a timeout) before shutting itself down.

Good luck! I bet the community would love to have a tutorial with what you learn getting this set up and working. :wink: I was going to but never got to test my setup thoroughly and now the information has left my brain.

1 Like

Hi Rich

I knew somebody here would know

From what I read if I connect a ups too my nas via USB it hosts its own NUT Server and you can connect clients that way I’m assuming I could connect my Windows machine as a client and also the rpi running OH

The nas is a simple unit running linux you can ssh into the machine and make changes beyond factory NETGEAR do not like this and will void any support if you do this (my support windows has already ended

But I might grab a dedicated rpi that only runs the nut server

I also agree with this I will see how it goes and maby try a writeup

What UPS are you using?

All I can say is I was not paying for any network ups the prices were stupid

CyberPower CP1500AVRLCD. I have quite a lot powered off of this thing (desktop form factor server, wifi router, pfSense server, cable modem, etc). I did the usual calculate the Watta / VA I need to run what I have + 20% and this one fit the bill.

I got a good deal on it and I knew ahead of time that it had a Linux driver I could install. I was planning on just cobbling something together using their tool until I discovered NUT.

I can’t say I did much research. I’m sure there are plenty of better ones out there. I say the deal, made sure I could access it from Linux and that it was powerful enough to drive my system and went for it.

I probably way bought though. That two hour outage last week only use up around 10% of the battery. I can probably go most of the day without power on this thing.

Mine hasent got that much room as its only a 700va but my network only pulls around 100watts so as my first ups it will do a fine job for now if I can get nut up and running


I have conected the UPS to my NAS with the USB cable it was recognised fine

I have also installed WinNUT on my Win 10 machine and changed the config file I’m not sure about it shutting itself down but it does seems to work just fine I switched the UPS off at the wall and the NAS reported a power outage I checked the log of winnut and it changed from charg to discharge


How will this work on Rasberry PI the one running my OH will it gracefully shutdown the system or will I have too come up with something like a script too stop OH and poweroff


Do you know a way too veiw the data about the UPS battery level runtime ect

Do you know how too pull this information into OH for presentation on habpannel ect

@rlkoshak should we have a binding for this? Or is it possible already without too much hassle? This use case certainly comes under radar of automation system. Thanks @Sharpy for brigning this up.

I happen to like APC UPSes for their USB reporting features.
Let me know what you guys think, I can make it happen.

On Linux at least /etc/nut/upsmon.cfg has a SHUTDOWNCMD where the command that get’s called is defined. By default it is set to /sbin/shutdown -h +0. I believe shutdown -h will cause systemd to stop all the running services before halting the machine.

You can test that by plugging the RPi into a monitor and watching the text that scrolls by after issuing the shutdown -h command yourself. If you see OH listed as one of those services then OH get’s shutdown nicely before the machine halts.

If not you can easily add that to the SHUTDOWNCMD parameter:

/bin/systemctl stop openhab; /sbin/shutdown -h +0

Using the Netowrk UPS Tool binding. Configure it with the device, host, port, login, and pass configured in the NUT server in “networkupstool.cfg”. Then configure your Item according to the binding README.

When you run upsc ups@nutserver it will print out all of the pieces of information reported by your UPS to NUT. At least for me, battery charge is in battery.charge and run time is battery.runtime. I don’t know how normalized the data is across different UPS models. I have the ups defined as “ups1” in the cfg file so my Item for the battery charge is

Number vUps_Charge "UPS Battery Level [%d]"
    { networkupstools="ups1:battery.charge", expire="2m"  }

and for runtime is

Number vUps_Runtime "Battery Runtime [%d]"
    { networkupstool="ups1:battery.runtime", expire="2m" }

These are the primary two fields I have interested in for OH integration but there is all sorts of other info available.

Unless I’m mistaken there already is a NUT binding. Or are you proposing a binding to do something else?

1 Like


Ok thanks for that i will look into both and post back

Is the binding good enough or the docs good enough? If yes, then user shouldn’t be in trouble.

Once I got NUT installed and configured the Oh part was easy.

All I would say is a 2.x version of the binding would be nice. But aren’t you supposed to be working on that Kotiln thing? :wink:

Yes, I am actually. But we also have to queue and summarize the outstanding work, a kind of shopping list for new devs or new Kotlin devs. :wink:

im getting error trying too setup the network ups binding haven’t added the rpi too the ups yet

2018-08-29 22:18:36.069 [ERROR] [ools.internal.NetworkUpsToolsBinding] - Nut processing error

org.networkupstools.jnut.NutException: VAR-NOT-SUPPORTED

	at org.networkupstools.jnut.Client.detectError(Client.java:407) [238:org.openhab.binding.networkupstools:1.12.0]

	at org.networkupstools.jnut.Client.get(Client.java:503) [238:org.openhab.binding.networkupstools:1.12.0]

	at org.networkupstools.jnut.Device.getVariable(Device.java:236) [238:org.openhab.binding.networkupstools:1.12.0]

	at org.openhab.binding.networkupstools.internal.NetworkUpsToolsBinding.execute(NetworkUpsToolsBinding.java:102) [238:org.openhab.binding.networkupstools:1.12.0]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [201:org.openhab.core.compat1x:2.3.0]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [201:org.openhab.core.compat1x:2.3.0]

I instaled the binding changed the config file

# Refresh interval for state updates in milliseconds (optional)

# UPS device name

# UPS server hostname (optional) // my nas with the usb from ups connected 

# UPS server port (optional)

# UPS server login (optional) // i have added these same problem

# UPS server pass (optional) // i have added these same problem

and created items

Number Ups_Output_Voltage "UPS output voltage [%.1f V]" {networkupstools="ups1:output.voltage"}
String Ups_Status "UPS status [%s]"  {networkupstools="ups1:ups.status"}

im assuming this error is because i dont know what the names are of what my ups is reporting or have i done this wrong maby my readynas does weird stuff too the nut server

any pointers for finding out whats going on ?

I am using my Snology NAS connected to the UPS (APC) to make this information available. The NAS recognizes the UPS (connected via USB) and you can query the data from OH with the snmp binding (Synology NAS has a builtin snmp server). I have OH items for UPS status, UPS load und UPS remaining minutes.

i’m not sure if my nas supports SNMP its ok but its nowhere near as advanced as a synology

Did you configure users and password on the NUT server? I never set anything up without so don’t know how that works.

I left the port commented out since I’m using the default port. Make sure the NUT server on your NAS also uses the default port.

I’d install the NUT client stuff on the RPi, you’re going to have to anyway, and see what upsc says from the RPi.

Make sure the device name matches what is configured in the NUT server, including case.

I was also surprised when I found out that my Snology NAS makes each cheap UPS “network ready”. It is even cheaper to purchase a normal (just USB interface) UPS and a small Synology NAS than buying a UPS with network interface.

no i didn’t get too change anything like that i plugged the ups into the nas with the usb cable and that was that it setup the nut sever on its own (NETGEAR must set this up before hand and hide the options from the user)

when linking the windows 10 machine too the nas i used the default port and that seems too be working

it just has the name UPS

these are the only options available for the ups on my nas the nut server was auto setup


@vossivossi i have looked and my nas does support SNMP but i doubt it broadcasts any ups information here

All I can recommend is setting up the Linux client and networkupstool.cfg with the same configuration as you did WinNut. Get the NUT client working on the RPi first since you have to do that anyway and you might get more useful error messages as you go to help tell you what might be wrong.

Maybe it is worth a try. The SNMP stuff is very cumbersome, you need to google around to find the number codes for your UPS model. These are my SNMP items for the UPS monitoring:

String DS215_UPS_STATUS "UPS Status DS215j [%s]" <usvstatus> { snmp="<[]" }

String DS215_UPS_LOAD "UPS Load DS215j [%s]" <usvstatus> { snmp="<[]" }

Number DS215_UPS_LOADN			"UPS LoadN [%.2f ]"			<energy>	{ snmp="<[]" }

Number DS215_UPS_RESTMIN		"UPS Restmin [%.2f ]"			<energy>	{ snmp="<[]" }

The cryptic numbers behind the IP adress of the NAS are the SNMP codes.

1 Like


Thanks for that if i cant get nut running i will look into that


I’m struggeling to get this too work i have followed parts of the guide you linked for pointers but im getting errors there too i think the guide you linked is for plugging the usb directly into an rpi and not setting a rpi up as a client

any tips

I ran

apt-get install nut

edited conf

nano /etc/nut/ups.conf

with same details as on win 10 machine

do i need too add and edit this part if i’m connecting as moniter? i did try was getting error no usb ups

driver = usbhid-ups
port = auto


upsdrvctl start


Network UPS Tools - UPS driver controller 2.7.4
Error: no UPS definitions found in ups.conf

I also edited a file too netclient