HIDPowerDevice icon indicating copy to clipboard operation
HIDPowerDevice copied to clipboard

Attempting to use with NUT (Ubuntu) or Synology

Open rik-shaw opened this issue 2 years ago • 4 comments

Thank you for your great work, we are looking to do the same thing and I have purchased a Leonardo to match what you have done so far.

I have a goal of adding support for this to a Synology, which uses nut but with what I think are some custom wrappers around it which make it a bit confusing, so let's leave that alone for now and I am using a stock Ubuntu 22.04 install. I have added the 98-upower-hid.rules file, and I think it is reporting correctly now to the system:

$ upower -e
/org/freedesktop/UPower/devices/ups_hiddev0
/org/freedesktop/UPower/devices/DisplayDevice

$ upower -i /org/freedesktop/UPower/devices/ups_hiddev0
  native-path:          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.2/usbmisc/hiddev0
  vendor:               CPS
  model:                Arduino Leonardo
  serial:               PQ8BO2000467
  power supply:         yes
  updated:              Fri 10 Nov 2023 12:39:20 PM CST (16 seconds ago)
  has history:          yes
  has statistics:       yes
  ups
    present:             yes
    state:               discharging
    warning-level:       discharging
    time to empty:       1.5 hours
    percentage:          76%
    icon-name:          'battery-full-symbolic'

However, when attempting to configure nut, it seems it isn't getting detected correctly. Have you tried to use this with nut? Here are some output showing my confusion:

$ nut-scanner -U
Neon library not found. XML search disabled.
IPMI library not found. IPMI search disabled.
Scanning USB bus.
<nothing more so I think it isn't detected>

I have attempted to setup the various files in /etc/nut/ but without the scanner detecting it I think I can't get anywhere with it. Thanks for any guidance, and thanks again for the great work!

rik-shaw avatar Nov 10 '23 18:11 rik-shaw

Looking at journalctl -f when I plug it in shows this:

Nov 10 12:49:16 ee kernel: usb 1-1: new full-speed USB device number 5 using xhci_hcd
Nov 10 12:49:16 ee kernel: usb 1-1: New USB device found, idVendor=2341, idProduct=8036, bcdDevice= 1.00
Nov 10 12:49:16 ee kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Nov 10 12:49:16 ee kernel: usb 1-1: Product: Arduino Leonardo
Nov 10 12:49:16 ee kernel: usb 1-1: Manufacturer: Arduino LLC
Nov 10 12:49:16 ee kernel: usb 1-1: SerialNumber: HIDAJ
Nov 10 12:49:16 ee kernel: cdc_acm 1-1:1.0: ttyACM0: USB ACM device
Nov 10 12:49:16 ee kernel: hid-generic 0003:2341:8036.0004: hiddev0,hidraw0: USB HID v1.01 Device [Arduino LLC Arduino Leonardo] on usb-0000:00:14.0-1/input2
Nov 10 12:49:16 ee mtp-probe[2970]: checking bus 1, device 5: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
Nov 10 12:49:16 ee mtp-probe[2970]: bus: 1, device: 5 was not an MTP device

Maybe it isn't appearing to be a UPS (maybe the udev rule isn't quite right?) Still confused.

rik-shaw avatar Nov 10 '23 18:11 rik-shaw

Here is my ups.conf for nut:

$ cat /etc/nut/ups.conf
pollinterval = 1
maxretry = 3

[leo-ups]
    driver = usbhid-ups
    port = auto
    desc = "arduino-leonardo-smart-ups"
    vendorid = 2341
    productid = 8036

but alas, when I attempt to force start the driver for configs from the ups.conf I get messages that it can't find any matching devices:

$ sudo upsdrvctl -DDD start
Network UPS Tools - UPS driver controller 2.7.4

   0.000059	Starting UPS: leo-ups
   0.000066	3 remaining attempts
   0.000068	exec:  /lib/nut/usbhid-ups -a leo-ups
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
No matching HID UPS found
   0.218387	Driver failed to start (exit status=1)
<it will try 2 more times and then exit>

So I am still not certain the device is being detected (by nut) correctly, even though upower seems to know about it just fine. hmm??

rik-shaw avatar Nov 10 '23 18:11 rik-shaw

OK I didn't realize that #1 has a lot of discussion about NUT needing to be updated to use the patch that was accepted that would allow using interface > 0 (since before that nut was hardcoded to look at interface 0 and the Leonardo is set for HID communication on interface 2). Also in that thread I see discussions of Synology, some hackery to boards.txt etc to make it work.

So I will look into how to update nut on Synology and / or Ubuntu 22.04 for further testing. Thank you again, please if there is more or different directions I should be going I would appreciate any pointers.

rik-shaw avatar Nov 10 '23 21:11 rik-shaw

Thanks to help over on #1 I updated NUT to 2.8.0 on Ubuntu 22.04 (using a ppa) and now nut-scanner -U is seeing the Leonardo! (Partial) success! However, now upower -e does not show the Leonardo at all. So somehow it is now not recognized as a "battery"? Hmm still a bit confused but making some sort of progress at least.

rik-shaw avatar Nov 10 '23 21:11 rik-shaw