Green Cell USV 600VA (and probably many other UPSes, including APC) with OpenWrt
Just out of interest I bought a relatively cheap Chinese UPS called “Green Cell USV 600VA” on Amazon, which has an USB connector and two 230V output sockets. Relatively cheap, as for just 30% more one can get a APC USV with similar power output and many more sockets. For me a typical sign of “cheapness” is, if it adds a display with some fancy graphics and background light is always on. So it is just wasting power…
Anyhow, I gave it a try and I am not too happy with it. Foremost, it pulls quite some power from the battery, even if no load is connected, so efficiency is relatively low. It also does not register properly as USB device. And last but no least, it has no proper battery monitor. I test the UPS regularly, and after less than 2 years I figured the battery was dead. But this was not shown on the display, but by immediately breaking down when disconnected from the grid. When I put power back on, I got “F04” on the display and a lot of beeping. I don't need a display to know what the problem is. This battery lifetime is a bit short, my APC lasted at least 3 years and provided a proper warning before the battery died…
Anyhow, APCUPSD is (mainly) for APC devices, so I had to check out an alternative monitor solution. Another reason for checking an alternative is, that Synology also does not talk to APCUPSD. At least I was not able to find anything useful about that.
Thus, I tried NUT (Network UPS Tools) to see how it is working. Finally I migrated also my other APS UPS to NUT control, as it is much more generic than APCUPSD, which is also implied by the name… Installation is unfortunately much more complicated than APSUPSD - but that is maybe the price for a more general UPS configuration. I have to say, the first time it did drive me “nuts” to get everything done in order, so to say!
So let's go though it, step by step…
When using a standard OpenWrt installation on a device with USB ports, the USB core modules should be already installed. Anyhow, one might want to install some basic tools to check out connected devices. This is not mandatory, especially if you know what you connect, but for debugging it might help:
# opkg update && opkg install usbutils
Now we can use “lsusb” to check out connected USB devices. Here are the lines for the different types of UPS I own. The first two are self-explanatory, the last comes from this cheap “noname” Chinese UPS. Bus and device numbers may vary depending on your router and on which port you connected the UPS, while the ID and description should help you to decide what driver you will need:
# lsusb <...> Bus 001 Device 002: ID 051d:0002 American Power Conversion Back-UPS BE650G2 FW:497200G -497300G <...> Bus 002 Device 002: ID 051d:0002 APC Back-UPS ES 700G FW:871.O4 .I USB FW:O4 <...> Bus 001 Device 005: ID 0001:0000 MEC MEC0003
To use NUT, you have to install some packages. Basically it is enough to install the driver package, as all other dependent packages, including the NUT server, are installed in this step as well. “nut-driver-nutdrv_qx” is required for this “Green Cell” UPS, which we install below. For APC, at least for my devices, the driver “nut-driver-usbhid-ups” is required instead.
# opkg install nut-driver-nutdrv_qx
To simplify NUT installation, one can use now a LuCI app and do the rest via the web interface. Alternatively, one can modify the files under /etc/config/ directly or use UCI for that (the commands are shown in LuCI anyhow).
# opkg install luci-app-nut
Now, after logging out and back in again, one should see the “Services” menu with the item “Network UPS Tools”. Selecting it, allows configuration of the NUT Server. The order of the page is just the opposite of what is needed.
- First, scroll down to “Driver Configuration”. Enter “ups” and click on add. Check that “nutdrv_qx” is selected.
- Next, scroll up to “Driver Global Settings”, click on add. For “RunAs User” enter “root”.
- Again a bit higher, at “Adresses on which to listen”, click add and enter “0.0.0.0” as IP address.
- Finally, at “NUT user”, click add and enter “monuser” and “secret” as user/pw, keep role as “auxiliary”.
- If you also want to control your UPS, select “set variables” for allowed actions and “all” to instant commands.
The configuration name as well as this username and password allows to use a Synology NAS later, as it expects this to log-in and detect the UPS. Not too secure, right… Anyhow, all this is part of a protected VLAN network, where no external or user access is planned. You might restrict the IPs the server will listen too, but this is again only a minor security improvement. As far as I know, you can not simply change this on your Synology NAS.
Adding “all” to “allowed actions” is important, without it you will get “Unexpected response from upsd: ERR ACCESS-DENIED” when you try any command via upscmd (e.g. to toggle the annoying beeping on your UPS).
If you want to use the command-line way to set it up, the sequence would be like this (you will get this also via LuCI). It is not a good idea to modify the files in /etc/nut/* directly, when using OpenWrt. This (command-line) way, you can also do some basic checks as well:
# uci set nut_server.ups=driver # uci set nut_server.ups.driver='nutdrv_qx' # uci set nut_server.ups.port='auto' # uci set nut_server.driver_global=driver_global # uci set nut_server.driver_global.user='root' # uci add nut_server listen_address # uci set nut_server.@listen_address[-1].address='0.0.0.0' # uci add nut_server user # uci set nut_server.@user[-1].username='monuser' # uci set nut_server.@user[-1].password='secret' # uci set nut_server.@user[-1].upsmon='slave' # uci add_list nut_server.@user[-1].actions='set' # uci add_list nut_server.@user[-1].actions='fsd' # uci add_list nut_server.@user[-1].instcmd='add' # uci commit # upsdrvctl start # upsc ups battery.voltage: 13.8 device.type: ups <...> ups.type: offline / line interactive ups.vendorid: 0001 # upscmd -l ups Instant commands supported on UPS [ups]: beeper.toggle - Toggle the UPS beeper <...> test.battery.stop - Stop the battery test #
Furthermore, head to the “NUT CGI” tab on the “Network UPS Tools” page on LuCI and enable “Control UPS via CGI”. Also, click add and enter “ups” for the UPS name, “localhost” for the Hostname and select any display name (I took also “ups”). Save and apply - then you can use the “Go to NUT CGI” to check if it is working. This way one can also monitor the UPS and send commands as well:
Additionally, one might to set up some statistics again, which can be achieved by installing this packages:
# opkg install collectd-mod-nut luci-app-statistics
Afterwards, go to “Statistics” and “Setup” on the LuCI web page, select “General plugins” and enable “UPS”. A window pops up, where you have to enter again “ups@localhost”, as this is the configuration created previously. Best is to log out and in again and you should see the UPS statistics:
Ok, I hope I didn't forget anything. Oh, and the UPS statistics will not show up if the UPS device is switched off, despite the fact the USB interface is still there. That's because the UPS has a mechanical on/off switch. This can be a bit annoying, as some strange errors may come from that fact as well. So always check your UPS is up and running first and “upsc ups” gives a proper response (and not something like “Error: Driver not connected”).



