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.
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.
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. I was going to but never got to test my setup thoroughly and now the information has left my brain.
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
(UPDATE)
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
(QUESTION)
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
Also
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
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)
refresh=60000
# UPS device name
ups1.device=UPS
# UPS server hostname (optional) // my nas with the usb from ups connected
ups1.host=192.168.0.14
# UPS server port (optional)
ups1.port=3493
# UPS server login (optional) // i have added these same problem
#ups1.login=
# UPS server pass (optional) // i have added these same problem
#ups1.pass=
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
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 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:
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
[apc-1500]
driver = usbhid-ups
port = auto
running
upsdrvctl start
returns
Network UPS Tools - UPS driver controller 2.7.4
Error: no UPS definitions found in ups.conf