NUT server on Raspberry Pi or Ubuntu with Multiple UPS units

There are several videos on installing Network UPS Tools (NUT) on the Raspberry Pi. The best detailed instruction I’ve seen is:
https://www.youtube.com/watch?v=vyBP7wpN72c
Note: this includes a fix for a Tripp-Lite problem
However, this does not cover some specific instances where problems arise with multiple units from one manufacturer

There are 5 files to edit in order to get minimal functionality: nut.conf, ups.conf, uspd.conf, upsmon.conf, and upsd.users. There is a sixth for the web interface: hosts.conf. Some of these files contain interlocking information so what is in one file affects the function of another. That can make troubleshooting difficult when things to sideways.

Easy configs first.
nut.conf contains a single line MODE = status. There are 4 possible entries with the default of none which is the off state. It can be standalone, netserver or netclient. Use netserver if you ever expect it feed information to another NUT installation.
upsd.conf contains a single line LISTEN IPaddress port. This is for internal communication between various elements of a NUT install. Default is 127.0.0.1 3493.

upsd.user contains a block username with password and admin status either master or client.
[username]
password = xxxxxxxx
admin master

More complex configs

ups.conf: contains the unit name, driver, port, description (optional) and unique product identification information.
The description should look like this:
[MyUPSname]
driver = usbhid-ups
port = auto
desc = “CyberPower 1500”
vendorid = 0764
productid = 0501
pollinterval = 15

For a single unit, vendorid and productid are adequate. If you have multiple units they must be distinguished by some combination of vendor, product, serial, vendorid and productid. Not all are necessary; just the ones that produce a unique identification. This can be difficult if you have multiple units from the same manufacturer as they may have the same vendorid and productid. sudo nut-scanner -UN will produce the correct configuration that can be copied into the ups.conf file.


Here is where things get complicated for multiple units on a single monitor. You cannot always get a unique combination nor does nut-scanner always produce a working configuration. One complication is nut-scanner may produce a different result or fail for a unit when it is in combination with another as opposed to stand alone. Individually, the units can connect but cannot be successfully combined. I tested 6 CyberPower units. I was able to get 4 to function as two pairs but 2 units would never work in any combination. Part of the problem is some units do not produce a usable serial number and some will cause nut-scanner to fail when in combination with another unit. Seems that using the bus and device/port numbers together would work as a unique identifier then the vendorid and productid would be supplementary information for configuration but the input for port is limited to the tty terminal for serial connections and is ignored for USB.
Following the digital trail, looks like Eaton took over the project but no longer supports it. They have what appears to be a competing product for sale so don’t expect any updates to NUT. The source code SKD and documents are available at Github https://github.com/networkupstools/nut/tree/Eaton_SDK

The video was an installation on a Raspberry Pi 4. I tried it on a Raspberry Pi 3+ Model B. NUT installed but did not include the nut-scanner command. Found some scattered information about the missing command but nothing concrete to solve the problem.

Vendorid and productid: You can get the Model and ProductID from the usb-devices command or from lsusb command. An example format for lsusb is
Bus 001 Device 012: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
The 0764:0501 are the vendorid:productid which is adequate for a single ups connection.
You can get more detail using lsusb -s 1:12 -v or lsusb -d 0764:001 -v
If you use usb-devices, you may find the model name is not the same as found in lsusb description even though the vendorid and productid are the same.

pollinterval: After getting the correct driver, I installed the web server and successfully connected to the web page with the UPS data. However, it timed out and would display stale data warning after about 20 minutes. A quick check of the problem is to run sudo upsdrvctl start and the data refreshes. Troubleshooting information from other posts indicated that NUT and UPS were timing out at different intervals so NUT thought the UPS was offline and offered up a stale data warning. Fixing it led down several blind alleys. Turns out neither MAXAGE nor DEADTIME have any effect on this. You need to include pollinterval = 15 in the device description; it will not work outside the device description. This problem may be specific to CyberPower but may occur with others.
driver:usbhid-ups is the only driver you can use with USB connected devices. Details are at: https://networkupstools.org/docs/man/usbhid-ups.html

upsmon.conf: contains the name of the unit to be monitored with @localhost, a digit, admin password and status
MONITOR CyberPower@localhost 1 admin password master. The name comes from ups.conf file; the password comes from uspd.users. For the upsc command, just the name is adequate The digit is 0 if no UPS is powering the monitoring computer, 1 if a single UPS powers the monitoring computer. Higher numbers indicate the total UPS units powering the computer. If a computer has 4 UPS units powering it but only 2 are needed to provide adequate power, the shutdown command needs to be adjusted so it won’t trip when 1 UPS goes offline.

Web page:

Firewall: The Apache installation on the Raspberry Pi went smoothly and the firewall was automatically configured for the NUT web page. However, the Ubuntu machine had a UFW and automatic configuration did not occur. It was only necessary to open port 80 and it worked.

RDP to Ubuntu 18.0.4, 20.04, 22.04 and Raspberry Pi

The usual instructions to connect from Windows via RDP to Ubuntu failed on18.0.4. The problem is a dependency in a needed package has been broken in the installation of XRDP on Ubuntu.  The fix is to install xorgxrdp manually but it is missing dependencies so you have to install xserver-xorg-core first. However, that also uninstalls some packages needed for mouse and cursor control in an RDP session so you add them back with xserver-xorg-input-all. After that, you can install xorgxrdp manually and the connection works.
The web page with write up on details is: https://c-nergy.be/blog/?p=13390
The broken dependencies in XRDP seem to have been corrected in the 20.04 install.

Still some flakey stuff about color scheme authorization when you connect but that’s more of a nuisance.

Update 1 Aug 2021
Found the web site which correctly address the color scheme authorization problem. I used it for Ubuntu 20.04 since I had the same problem with it as I did with 18.0.4.

Xrdp – Connect Ubuntu Linux Remote Desktop via RDP from Windows

One gottcha is you have to log out of Ubuntu before you attempt the remote desktop, otherwise all you get is a blank screen. Likewise logout of Ubuntu when exiting the RDP session, otherwise you get a blank screen when trying to login in to the physical box. Reboot is necessary to clear it. Might be a command line session you can do from putty but rebooting is quick and easy.

For Raspberry Pi, the process is much easier. Just install XRDP. The connection spawns a new window so you can have one window on the Raspberry Pi while working on a completely different window in the RPD session.

Update 2 Nov 2022

For Ubuntu 22.04 the problems have been addressed and installation is trivially easy.

Change to the root account for all commands to work.
sudo -i
install xrdp
apt install xrdp
Add xrdp to the certificate. Must be root to work.
usermod -a -G ssl-cert xrdp
Modify the firewall
ufw allow 3389/tcp
ufw allow 3389/udp

Logoff before trying RDP from windows. There will be 2 additional password authentications on connection to enable color pallet and color device management. This is for local users not AD users.

Active Directory authentication for RDP session
If the Ubuntu box is active directory domain joined for user authentication, the domain users cannot authenticate without some changes to the sssd.conf file.
sudo -i
cd /etc/sssd
nano sssd.conf
add 2 lines
ad_gpo_access_control = enforcing
ad_gpo_map_remote_interface = +xrdp-sesman
restart sssd

For domain user name use the full domain in the format
user@nameof.domain

Another option.
You can also go to settings, enable remote desktop, check enable legacy VNC protocol. This has slightly different login behavior with the authentication requests: one for color pallet and another for keyring unlock. However, the 2 procedures do not conflict and both can be active at the same time. You still get an xrdp login box under RDP.

I removed VNC and tried to connect with RDP and could not authenticate. RDP would not even connect to the remote machine unless I was logged in on the remote machine. This is xrdp behavior where you must be logged out to authenticate even though a connection can be made. From some posts, it appears this protocol is showing the same screen and the person logged in, not spawning a new one. After some more searching, this login failure appears to be a common problem with no definitive answer for now. Some people get it to work, others can’t.