[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 responseError: 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:
- 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. - 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 wasusbhid-ups
. I’ll pretend the name it gave wassparky
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
- 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"
- 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
- restart nut monitor:
$ sudo service nut-server restart
- 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
- 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/*
- restarted nut monitor with
$ sudo service nut-server restart
- 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
- I can’t find a guide to ‘un-chown’ things, and I’m ashamed to say I don’t even know what
- 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!