[solved] Messed up my UPS installation and can't figure out how to un-mess it up

[solution]: I typed $ sudo upsdrvctl start and then everything worked as expected. Despite /etc/nut/ups.conf describing the UPS exactly per the comment text in the .conf file, upsdrvctl wouldn’t let me start the UPS by name; I had to use the general start command (IE instructing it to start all UPSs). I’m not sure why this was the case.

My YunoHost server

Hardware: Old computer, Amazon Basics Uninterruptible Power Supply (UPS).
YunoHost version: 11.2.6
I have access to my server : Using SSH but can use direct access via keyboard if required
special context? : no

Context:

  • I’m a noob
  • I’m trying to do everything via the Yunohost web interface, and keep things as vanilla as possible, but I’ve accepted that setting up a UPS will require using the command prompt.
  • I purchased a cheap UPS and am having trouble getting it to work with my Yunohost PC.
  • I’ve been trying to follow the information in these guides:

Questions:

  • Does typing $ sudo upsc sparky elicit the response Error: Driver not connected because the driver couldn’t be started using $ sudo upsdrvctl start sparky?
  • About half-way through doing all this, using the command $ upscmd -l sparky worked correctly… could the fact that it now doesn’t work be because I tried to restrict permissions by typing $ sudo chown root:nut /etc/nut/* and then $ sudo chmod 640 /etc/nut/*?
    • if so, is there a way to remove this restriction?
  • Are there any other not-too-scary guides I could try reading?
  • I thought about using apcupsd because @ejmroberge described good results with it. Unfortunately the Debian wiki says it needs sys-v to function, and understanding fully the implications of switching from sysv to systemd is beyond my ability (and nor would I really know how to switch back if I later needed to)! Is there an alternative to nut that I should consider that is likely to ‘just work’?

What I’ve done so far:

  1. install nut: SSH into the yunohost server and install nut by typing $ sudo apt-get install nut; installing the nut package installs the nut user and group.
  2. gather info about the UPS:
  • type $ sudo nut-scanner -U, and I learn the name assigned to the UPS, the driver, and the port.
  • It told me the port was auto and the driver was usbhid-ups. I’ll pretend the name it gave was sparky because I don’t really understand the implications of sharing names like that!
Scanning USB bus.	
[sparky]	
	driver = "usbhid-ups"
	port = "auto"
	vendorid = "06DA"
	productid = "FFFF"
	product = "Offline UPS"
	serial = "000000000"
	vendor = "PPC"
	bus = "001"
  • type $ lsusb -v to get (I’ve just cropped it to the output for the device concerned):
Bus 001 Device 054: ID 06da:ffff Phoenixtec Power Co., Ltd Offline UPS
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x06da Phoenixtec Power Co., Ltd
  idProduct          0xffff 
  bcdDevice            0.03
  iManufacturer           1 PPC
  iProduct                2 Offline UPS
  iSerial                 4 000000000   
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0022
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     495
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval             100
  • type $ sudo cat /proc/tty/driver/serial to get:
serinfo:1.0 driver revision:
0: uart:16550A port:0000F0E0 irq:19 tx:0 rx:0 CTS|DSR|CD
1: uart:unknown port:000002F8 irq:3
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3
  1. set up nut’s ups.conf by editing it with $ sudo nano /etc/nut/ups.conf, and adding the lines
[sparky]
    driver=usbhid-ups
    port=auto
    desc="humanreadabledescription"
  1. to check I’m now connected, I view the available commands for a UPS by using the -l modifier for upscmd: $ upscmd -l sparky, or to view all it’s available data type: $ upsc sparky
  • at this stage it seemed to work as intended
  1. restart nut monitor: $ sudo service nut-server restart
  2. allow upsmon to monitor the UPS by editing upsmon.conf. Typed: $ sudo nano /etc/nut/upsmon.conf, and then added the line: MONITOR sparky@localhost 1 myusername thepassword master
  3. now I’ve put sensitive data in these files (I.E.: passwords), so I wanted to fix the permissions. Typed $ sudo chown root:nut /etc/nut/*, and then $ sudo chmod 640 /etc/nut/*
  4. restarted nut monitor with $ sudo service nut-server restart
  5. now checked it has no complaints by typing: $ sudo service nut-server status.
  • this returns:
nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/lib/systemd/system/nut-server.service; enabled; vendor pr>
     Active: active (running) since Tue 2023-11-28 21:51:38 GMT; 1 weeks 2 days>
   Main PID: 302133 (upsd)
      Tasks: 1 (limit: 19031)
     Memory: 624.0K
        CPU: 33.746s
     CGroup: /system.slice/nut-server.service
             └─302133 /lib/nut/upsd

Dec 08 17:50:50 subdomain.domain.tld upsd[302133]: Can't connect to UPS [sparky] (usbhid>
Dec 08 17:55:50 subdomain.domain.tld upsd[302133]: Can't connect to UPS [sparky] (usbhid>
Dec 08 18:00:50 subdomain.domain.tld upsd[302133]: Can't connect to UPS [sparky] (usbhid>
Dec 08 18:05:51 subdomain.domain.tld upsd[302133]: Can't connect to UPS [sparky] (usbhid>

and it just keeps repeating the last line.

My best guess is that this went south after I changed the permissions.

In closing:

  • is this just a permissions problem?
    • I can’t find a guide to ‘un-chown’ things, and I’m ashamed to say I don’t even know what chmod 640 did :face_with_peeking_eye: :face_with_peeking_eye:
  • is there a better/more-established way to manage a UPS?
  • I’m grateful for any steer anyone can give, even if it’s just to tell me what other information I ought to provide!

As always, this goes out with emphatic thanks to all the devs, moderators, documentators, admins, and other heroes who keep all this spinning out of the kindness of their hearts!

Just to add I’m trying to work through the NUT FAQ to understand the best course of action.

I understand chown 640 is actually a base 2 (binary) command to alter the permissions parameter for what are presumably originally -rw-r–r–

Hi splunko,

Good idea to have UPS on your Yunohost!

To get priorities right:

  • The UPS does deliver power to Yunohost when you disconnect the wall plug, to simulate power outage?
  • NUT does not provide information about state of the UPS, so you have to guess whether batteries are full and whether or not there is a power outage?

Did you find the not-mentioned model on the NUT-compatibility list?

Your opening post is elaborate enough, but I have some trouble following what I am reading. On top of your post are two links, but I can’t match the guides there to the steps you followed.

Anyway… Did you notice > at the end of

With some luck there is some information about what the problem is behind >. You can press the arrow butten → to show the rest of the line. The mentioned nutdev1 is sparky?

Yes, good find :wink: Now root can make changes (and read), members of the group nut can read the files. That seems ok, so I don’t think the problem is in your step 7. If you undo the changes in step 6 and restart nut-server, does it give the current error, or the previous ‘no problem’ result?

My thought is: there are two components, so probably one connects to the UPS, the other monitors the driver. As long as you don’t tell the monitor what to monitor, all is fine. After you tell it to monitor something, that something has to have the right configuration. If not, errors follow.

I searched for the vendor/product ID’s, and found [HCL] BlueWalker / PowerWalker VI 650/850 SHL (2018+ Models) supported by usbhid-ups · Issue #646 · networkupstools/nut · GitHub ; could that be of any help? The issue was closed over a year ago, but with Yunohost running on Debian 11, the issue might still exist in NUT that is installed.

1 Like

:heart_eyes:

Thank you for taking the time to write such a super reply!

You are right; I read both guides and I’ve merged them (in my mind!) to try to meet my specific needs, for alas neither was perfectly written for my situation… perhaps this was my first folly.

The UPS does deliver power to Yunohost when you disconnect the wall plug, to simulate power outage?

This is correct: it does deliver power with the wall plug unplugged.

NUT does not provide information about state of the UPS, so you have to guess whether batteries are full and whether or not there is a power outage?

This is correct. Nut does not provide information about the state of the UPS for me.

Did you find the not-mentioned model on the NUT-compatibility list?

You’re very polite! It’s an Amazon Basics UPS. There’s no mention of it in the compatibility list. I was reassured that, using the usbhid-ups driver, $ upsc sparky worked to view it’s available data (sorry I didn’t copy that!) but clearly I’ve cocked it up somehow as it no longer works. I’m also reassured (as you spotted) that the PowerWalker VI 650 SHL (which also identifies as 06da:ffff Phoenixtec Power Co.) seems supported by usbhid-ups.

A good web searching suggests to me it’s full title is an: AmazonBasics Aurora Vista 850 IEC UPS, USB (9E62-53057DZ1) picture here, although sadly that doesn’t appear in the compatability list!

Did you notice >

The line in question, now in full (thanks!) is:

 Can't connect to UPS [sparky] (usbhid-ups-sparky): No such file or directory

Also, now when I type $ upsc sparky, I get;

Init SSL without certificate database
Error: Driver not connected

and when I type $ sudo service nut-server status, I get:

● 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 Sun 2023-12-31 18:17:39 GMT; 29s ago
    Process: 1429853 ExecStart=/sbin/upsd (code=exited, status=0/SUCCESS)
   Main PID: 1429854 (upsd)
      Tasks: 1 (limit: 19031)
     Memory: 616.0K
        CPU: 6ms
     CGroup: /system.slice/nut-server.service
             └─1429854 /lib/nut/upsd

Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: ACL in upsd.conf is no longer supported - switch to LISTEN
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: Can't connect to UPS [sparky] (usbhid-ups-sparky): No such file or directory
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: ACL in upsd.conf is no longer supported - switch to LISTEN
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: ACCEPT in upsd.conf is no longer supported - switch to LISTEN
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: REJECT in upsd.conf is no longer supported - switch to LISTEN
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: listening on 127.0.0.1 port 3493
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: listening on ::1 port 3493
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429853]: Can't connect to UPS [sparky] (usbhid-ups-sparky): No such file or directory
Dec 31 18:17:39 subdomain.mydomain.tld upsd[1429854]: Startup successful
Dec 31 18:17:39 subdomain.mydomain.tld systemd[1]: Started Network UPS Tools - power devices information server.

Oh my days; perhaps the smoke might be beginning to clear: could this be because - thinking I was being secure - I added the following lines to /etc/nut/upsd.conf and then forgot to include that step in my write-up above?

    ACL all 0.0.0.0/0
    ACL localhost 127.0.0.1/32
    ACCEPT localhost
    REJECT all

Addendum:

Very sadly when I delete the above 4 lines and replace them with LISTEN 127.0.0.1 32 or LISTEN 127.0.0.1 3493, and then type $ sudo service nut-server restart then $ sudo service nut-server status, I am given

● 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 Sun 2023-12-31 18:51:42 GMT; 1min 31s ago
    Process: 1430690 ExecStart=/sbin/upsd (code=exited, status=0/SUCCESS)
   Main PID: 1430691 (upsd)
      Tasks: 1 (limit: 19031)
     Memory: 620.0K
        CPU: 9ms
     CGroup: /system.slice/nut-server.service
             └─1430691 /lib/nut/upsd

Dec 31 18:51:42 subdom.dom.tld systemd[1]: Starting Network UPS Tools - power devices information server...
Dec 31 18:51:42 subdom.dom.tld upsd[1430690]: fopen /run/nut/upsd.pid: No such file or directory
Dec 31 18:51:42 subdom.dom.tld upsd[1430690]: listening on 127.0.0.1 port 3493
Dec 31 18:51:42 subdom.dom.tld upsd[1430690]: listening on 127.0.0.1 port 3493
Dec 31 18:51:42 subdom.dom.tld upsd[1430690]: Can't connect to UPS [sparky] (usbhid-ups-sparky): No such file or directory
Dec 31 18:51:42 subdom.dom.tld upsd[1430690]: Can't connect to UPS [sparky] (usbhid-ups-sparky): No such file or directory
Dec 31 18:51:42 subdom.dom.tld upsd[1430691]: Startup successful
Dec 31 18:51:42 subdom.dom.tld systemd[1]: Started Network UPS Tools - power devices information server. 

(the same output with an adjusted port number is given when trying with port 32). Up to date guide to upsd.conf is here.

I hope my output has some use to yourself or any other readers.

I remain open to suggestion! I’d be curious to try whatever port is represented by “0000F0E0” as $ sudo cat /proc/tty/driver/serial gave

serinfo:1.0 driver revision:
0: uart:16550A port:0000F0E0 irq:19 tx:0 rx:0 CTS|DSR|CD

But I might be barking up the wrong tree.

My thanks again for your kindness.

Oh my days.

$ sudo upsdrvctl start and then $ upsc sparky yields:

Init SSL without certificate database
battery.charge: 100
battery.runtime: 3600
battery.type: PbAc
device.mfr: PPC
device.model: Offline UPS HID UPS
device.serial: 000000000   
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: MGE HID 1.40
driver.version.internal: 0.41
input.voltage: 241.0
outlet.1.status: on
output.frequency: 50.3
output.frequency.nominal: 50
output.voltage: 241.0
output.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 4
ups.mfr: PPC
ups.model: Offline UPS HID UPS
ups.power.nominal: 3
ups.productid: ffff
ups.serial: 000000000   
ups.status: OL
ups.test.result: No test initiated
ups.timer.shutdown: 0
ups.timer.start: 0
ups.type: offline / line interactive
ups.vendorid: 06da

I believe I have solved it; @wbk thank you so much for your help!

I will get on with setting it up at the first opportunity.

I must also (I presume) make a job so that, upon startup, $ upsdrvctl start gets entered by the root user…

Phew!!!

@wbk thank you again; had you not steered me, I would have spend a discouraging amount of time chasing a red herring. I’m much obliged.

I must add, in case someone else hits the same hurdle, that I came to this solution by plugging the UPS into my laptop (running arch) just to double-check I was right that usbhid-ups was the right driver. It may be that the act of unplugging it/replugging it in had something to do with it too!

1 Like

Hi splunko,

Thank you for your kind words. Glad to be of help, great that you got it working!

Have fun :slight_smile:

1 Like

:smiley: :smiling_face_with_three_hearts:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.