1. intro

Green Cell 360W UPS 600 VA - UPS01LCD

./pic/ups001.jpg

Based on different documentations found on the internet, we had a problem with the suggested blazer_usb driver. It does not allow to send commands trough upscmd such as shutdown.return. To overcome this problem we used another driver nutdrv_qx.

Now, our homeassistant is not happy with it since we do not have the battery.charge attributename anymore. We had to manually enable the battery.voltage attribute and now everything is working.

2. installation master

yum -y install libusbx usbutils nut
Installing:
 nut                                    x86_64                          2.8.0-3.el9                                epel                               2.1 M
Installing dependencies:
 freeipmi                               x86_64                          1.6.9-1.el9                                appstream                          2.0 M
 net-snmp-libs                          x86_64                          1:5.9.1-7.el9_0.1                          appstream                          742 k
 nut-client                             x86_64                          2.8.0-3.el9                                epel                               205 k
systemctl disable --now \
  nut-driver@.service \
  nut-server.service \
  nut.target \
  nut-monitor.service \
  nut-driver-enumerator.service \
  nut-driver.target
systemctl enable --now nut-driver@greenUPS.service nut-server.service

3. debug

allways start the driver first before the server

nutdrv_qx -a greenUPS
Network UPS Tools - Generic Q* USB/Serial driver 0.32 (2.8.0)
USB communication driver (libusb 1.0) 0.43
Using protocol: Q1 0.07
Can't autodetect number of battery packs [-1/13.90]
Battery runtime will not be calculated (runtimecal not set)
upsd -FF -D
 Network UPS Tools upsd 2.8.0
   0.000000     fopen /run/nut/upsd.pid: No such file or directory
   0.000222     Could not find PID file '/run/nut/upsd.pid' to see if previous upsd instance is already running!

   0.002357     [D1] debug level is '1'
   0.007155     listening on 0.0.0.0 port 3493
   0.025933     Connected to UPS [greenUPS]: nutdrv_qx-greenUPS
   0.037523     Running as foreground process, but saving a PID file anyway
   0.039123     [D1] Saving PID 193297 into /run/nut/upsd.pid

3.1. debian

apt -y install nut

4. configuration

rm /etc/nut/*
wget -N -nv http://d01cid.ddns.net/sharel/etc/nut/nut.conf -P /etc/nut/
wget -N -nv http://d01cid.ddns.net/sharel/etc/nut/ups.conf -P /etc/nut/
wget -N -nv http://d01cid.ddns.net/sharel/etc/nut/upsd.conf -P /etc/nut/
wget -N -nv http://d01cid.ddns.net/sharel/etc/nut/upsd.users -P /etc/nut/
chmod 640 /etc/nut/*
chown nut:users -R /etc/nut/
systemctl daemon-reload
systemctl disable --now nut-driver.service nut-server.service nut-client.service nut-monitor.service
systemctl enable --now nut-driver.service nut-server.service
systemctl status nut-driver.service nut-server.service
* nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/lib/systemd/system/nut-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-03-29 16:21:45 CEST; 3min 42s ago
   Main PID: 2010534 (upsd)
      Tasks: 1 (limit: 18998)
     Memory: 668.0K
        CPU: 6ms
     CGroup: /system.slice/nut-server.service
             `-2010534 /lib/nut/upsd

Mar 29 16:21:45 kvm010.d01.net systemd[1]: Starting Network UPS Tools - power devices information server...
Mar 29 16:21:45 kvm010.d01.net upsd[2010533]: fopen /run/nut/upsd.pid: No such file or directory
Mar 29 16:21:45 kvm010.d01.net upsd[2010533]: listening on 0.0.0.0 port 3493
Mar 29 16:21:45 kvm010.d01.net upsd[2010533]: listening on 0.0.0.0 port 3493
Mar 29 16:21:45 kvm010.d01.net upsd[2010533]: Connected to UPS [greenUPS]: nutdrv_qx-greenUPS
Mar 29 16:21:45 kvm010.d01.net upsd[2010533]: Connected to UPS [greenUPS]: nutdrv_qx-greenUPS
Mar 29 16:21:45 kvm010.d01.net upsd[2010534]: Startup successful
Mar 29 16:21:45 kvm010.d01.net systemd[1]: Started Network UPS Tools - power devices information server.

* nut-driver.service - Network UPS Tools - power device driver controller
     Loaded: loaded (/lib/systemd/system/nut-driver.service; static)
     Active: active (running) since Wed 2023-03-29 16:21:45 CEST; 3min 43s ago
   Main PID: 2010532 (nutdrv_qx)
      Tasks: 1 (limit: 18998)
     Memory: 992.0K
        CPU: 13ms
     CGroup: /system.slice/nut-driver.service
             `-2010532 /lib/nut/nutdrv_qx -a greenUPS

Mar 29 16:21:41 kvm010.d01.net systemd[1]: Starting Network UPS Tools - power device driver controller...
Mar 29 16:21:44 kvm010.d01.net upsdrvctl[2010521]: Using protocol: Q1 0.07
Mar 29 16:21:45 kvm010.d01.net upsdrvctl[2010521]: Battery runtime will not be calculated (runtimecal not set)
Mar 29 16:21:45 kvm010.d01.net upsdrvctl[2010520]: Network UPS Tools - UPS driver controller 2.7.4
Mar 29 16:21:45 kvm010.d01.net nutdrv_qx[2010532]: Startup successful
Mar 29 16:21:45 kvm010.d01.net systemd[1]: Started Network UPS Tools - power device driver controller.

5. testing

upsc greenUPS
Init SSL without certificate database
battery.voltage: 13.80
device.type: ups
driver.name: nutdrv_qx
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: Q1 0.07
driver.version.internal: 0.28
input.frequency: 49.9
input.voltage: 236.8
input.voltage.fault: 228.4
output.voltage: 236.7
ups.beeper.status: enabled
ups.delay.shutdown: 30
ups.delay.start: 180
ups.load: 4
ups.productid: 0000
ups.status: OL
ups.type: offline / line interactive
ups.vendorid: 0001
upscmd -l greenUPS
Instant commands supported on UPS [greenUPS]:

beeper.toggle - Toggle the UPS beeper
load.off - Turn off the load immediately
load.on - Turn on the load immediately
shutdown.return - Turn off the load and return when power is back
shutdown.stayoff - Turn off the load and remain off
shutdown.stop - Stop a shutdown in progress
test.battery.start - Start a battery test
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test

6. the big magic: rups

6.1. master

source /etc/cid.conf
curl -ns http://${rdsserver}/sharel/bin/inst-httpd | bash
curl -ns http://${rdsserver}/sharel/img/rups/rups-20221225.tgz | tar xzP -C /
sed -i s~'upsRole = .*'~'upsRole = "greenUPS"'~ /opt/rups/etc/rups.conf
sed -i s~'upsRole = .*'~'upsRole = "master"'~ /opt/rups/etc/rups.conf
systemctl reload apache2.service
sed -i s~"#\*/1 "~"\*/1 "~ /etc/cron.d/cid-cron
echo "/opt/rups/bin/rups" >> /bin/cid-cron01

6.2. slave

source /etc/cid.conf
curl -ns http://${rdsserver}/sharel/img/rups/rups-20221225.tgz | tar xzP -C /
sed -i s~'upsRole = .*'~'upsRole = "slave"'~ /opt/rups/etc/rups.conf
sed -i s~"#\*/1 "~"\*/1 "~ /etc/cron.d/cid-cron
echo "/opt/rups/bin/rups" >> /bin/cid-cron01

7. rups testing

curl -s http://ups.d01.net/rups/
#
ups_date="20220819"
ups_time="23:02:01"
ups_batt="13.90"
ups_volt="230"
ups_load="4"
ups_stat="OL"

8. debugging (on the master)

yum -y install usbutils
lsusb
Bus 001 Device 002: ID 0001:0000 Fry's Electronics <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
nut-scanner -U
Neon library not found. XML search disabled.
AVAHI client library not found. AVAHI search disabled.
Scanning USB bus.
[nutdev1]
        driver = "nutdrv_qx"
        port = "auto"
        vendorid = "0001"
        productid = "0000"
        product = "MEC0003"
        vendor = "MEC"
        bus = "001"
Tip nutdrv_qx -DD -a greenUPS

9. references

10. bug in el9

nut-scanner -U
nut-scanner: error while loading libusb-1.0.so.0 from libusb-0.1.so.4: libusb-1.0.so.0: cannot open shared object file: No such file or directory
Segmentation fault (core dumped)
Cannot load SNMP library (/usr/lib64/libnetsnmp.so.40.1.0) : /usr/lib64/libnetsnmp.so.40.1.0: undefined symbol: usmDESPrivProtocol. SNMP search disabled.
Neon library not found. XML search disabled.
AVAHI client library not found. AVAHI search disabled.
Scanning USB bus.

11. compile on debian

vi /etc/apt/sources.list
///
deb-src http://ftp.belnet.be/debian/ bullseye-updates main
 apt -y build-dep nut
# apt -y install automake gcc g++ git
 apt -y install git
 git clone https://github.com/networkupstools/nut.git
 cd nut/; ./autogen.sh
 ./configure --prefix=/usr \
    --includedir=/usr/include --mandir=/usr/share/man \
    --infodir=/usr/share/info --sysconfdir=/etc/nut --localstatedir=/var \
    --libexecdir=/usr/lib/nut --srcdir=. --enable-maintainer-mode \
    --disable-silent-rules --libdir=/usr/lib/`gcc -print-multiarch` \
    --with-ssl --with-nss --with-cgi --with-dev --enable-static \
    --with-statepath=/var/run/nut --with-altpidpath=/var/run/nut \
    --with-drvpath=/lib/nut --with-cgipath=/usr/lib/cgi-bin/nut \
    --with-htmlpath=/usr/share/nut/www --with-pidpath=/var/run/nut \
    --datadir=/usr/share/nut --with-pkgconfig-dir=/usr/lib/`gcc -print-multiarch`/pkgconfig \
    --with-user=nut --with-group=nut --with-udev-dir=/lib/udev \
    --with-systemdsystemunitdir=/lib/systemd/system