-
-
Notifications
You must be signed in to change notification settings - Fork 391
Description
Greetings. I've got a single Smart-UPS X 1500 connected via USB to a Raspberry PI with nut installed with fairly basic configuration. Aside from locally getting data via the upsc command I also have nut-http set up to provide the same data via a HTTP API (end usecase is making a bitfocus companion module that is going to query that data). Nut is talking to the UPS via the usbhid-ups driver.
If I disconnect the usb cable - nut keeps reporting last known data, seemly unaware of the disconnect (both when asked via upsc or the http api). Expected behaviour after a usb disconnect would be seeing a "Driver not connected" error. I've tinkered with a bunch of settings, googled issues and chatgpt suggestions for a few hours now, but whatever I do it doesn't change this behavior. Here's some stuff I tried:
pollonly = "enabled"
in theups.conf
UPS setting- playing around with
pollinterval
andpollfreq
in the same config - playing around with
MAXAGE
inupsd.conf
- manual UPS port selection in
ups.conf
The curious thing is that it keeps returning stale data even after restarting the nut server (sudo systemctl resart nut-server
). The only 'soft' way I've found for it to figure out it's gone was either making an adjustment in ups.conf
or doing a hard usb driver restart for this UPS (/bin/systemctl restart nut-driver@[upsname].service
).
To poke it around some more I installed nut on my macbook, and plugged the UPS right in. It looks like it doesn't automatically keep the usb driver running after configuring the ups on mac like it does on linux. When running the usb driver manually and disconnecting the usb cable I see instantly see a nut_libusb_get_report: No such device (it may have been disconnected)
error, and the driver crashing shortly after - which is nice.
To explore some more I discovered you can tail the usb driver logs like so sudo journalctl -u nut-driver@[upsname].service -f
.
What I observe there is that the driver is infact well aware of the fact that a disconnect took place. Only in this case it keeps repeating the following:
96.184957 [D1] Can't retrieve Report 0f: No such device
96.184996 nut_libusb_get_report: No such device (it may have been disconnected)
Meanwhile the driver is still running, and both upsc and nut-http keep dumping old data. I haven't let it take quite a lot of time to see if it realizes eventually, but it definitely lasts for 5+ minutes which is unaccetable for my use case. Also, logically the MAXAGE
setting should tell nut to declare data as stale as quickly as after 15 seconds.
Anyone any clue what's going on here and what else I can try? Many thanks!