Gooserhino Posted October 17, 2021 Share Posted October 17, 2021 (edited) Hello All, Recently purchased a brand new APC UPS (BGM1500b) and am having issues connecting with both the built in UPS settings as well as the NUT plugin. Batteries are brand new and have passed a self-test. Using Unraid version 6.9.2. When connecting via the built in UPS settings I have the same error as detailed in this post with the UPS reporting "On Battery" status once it has reached 100% charge even though it is currently online. I have tried every variation of USB cable and type available in UPS settings and can only get unraid to recognize the UPS with cable and type both set to USB. When connecting to a windows machine the UPS status is reported correctly in powerchute software. After failing to get the built in UPS management to function properly I setup the NUT plugin and have issues with the UPS disconnecting after a day or two. I continue to get "Poll UPS failed - Data stale" errors with NUT that can only be corrected by pulling the USB and reinserting. Error is persistent regardless of USB port on my server and I have verified there are no USB power saving settings in my bios. I have also tried adjusting config values for MAXAGE, DEADTIME, and POLLINTERVAL to no avail. At this point I'm at a loss on a path forward and would appreciate any help that can be provided. Edited October 24, 2021 by Gooserhino Solved Quote Link to comment
grunter Posted October 19, 2021 Share Posted October 19, 2021 (edited) I too had trouble with a new APC UPS and UnRaid. I purchased an APC "Easy" UPS but could not get it to work using both the built in APC utility and the NUT plugin. This model seems to use a different connection scheme with a USB connector at each end of the cable. I installed my old APC Smart-UPS 650 and it automatically connected to the build in UPS feature and works flawlessly (its just a bit small and only gives me a few minutes run-time). This model used a USB cable at the PC end and the special 10-pin RJ plug at the UPS end. (I call an RJ plug because it looks like an RJ45 plug but has 10 pins instead of 8 pins). This appears to be a proprietary APC cable. I regret purchasing that Easy UPS and it seems from this forum that the Eaton range of UPS's may be a better device. Edited October 19, 2021 by grunter Quote Link to comment
Gooserhino Posted October 23, 2021 Author Share Posted October 23, 2021 I seem to have found a way to resolve my issues with NUT by using a scheduled script to reset the USB once NUT reports "data stale." Using the user script plugin here and this USB reset script here. https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line I used the command below in the user script plugin to call the usbreset script and execute by searching for the bus and device IDs of my UPS. To configure for a different UPS replace [American Power Conversion] with whatever your UPS is labeled as when using "lsusb" in the unraid terminal. Finally adjust the schedule setting in the user scripts plugin to however long it typically takes until NUT starts reporting "data stale" errors. https://crontab.guru/ is helpful for determining custom scheduling times. #!/bin/bash echo $(lsusb | grep "American Power Conversion"); APC=$( lsusb | grep "American Power Conversion" | perl -nE "/\D+(\d+)\D+(\d+).+/; print qq(\$1/\$2)") /path/to/usbreset/script /dev/bus/usb/$APC Quote Link to comment
Shadow Blitz Posted July 19, 2022 Share Posted July 19, 2022 Hello Gooserhino, I have the same issue as you had. I did try following your steps as I have perl installed though the nerd pack plugin and have the user scripts plugin installed. I created the usbreset script from the above post (the first big block of code that is on the site you linked) the usbreset script is located at /mnt/user/appdata/userscripts/usbreset on my server. and I chmod it with 777 and +x. then I created a script titled 'upsreset' and put your code into it but replaced '/path/to/usbreset/script' with '/mnt/user/appdata/userscripts/usbreset' and when I try and run it. I get this failed result. Script location: /tmp/user.scripts/tmpScripts/upsreset/script Note that closing this window will abort the execution of this script Bus 002 Device 006: ID 051d:0002 American Power Conversion Uninterruptible Power Supply /mnt/user/appdata/userscripts/usbreset: line 1: /bin: Is a directory /mnt/user/appdata/userscripts/usbreset: line 12: syntax error near unexpected token `(' /mnt/user/appdata/userscripts/usbreset: line 12: `int main(int argc, char **argv)' Any help would be appreciated. As I can't afford to buy a new UPS at this time and I would like to get this one to work in a way that I can have it set and forgotten and be reliable. Just for people who want to know, here is the details of my UPS. American Power Conversion Back-UPS BX1600MI FW:294201G -302201G Thank you. Quote Link to comment
Batman Posted August 20, 2022 Share Posted August 20, 2022 The error is because calling the c-code as a script won't do anything, because it's trying to interpret it as a shell script. I discovered that a version of "usbreset" is already present on Unraid, or at least it's built-in to version 6.10.2. Using that, I wrote a script I can schedule to check if the UPS is communicating and reset the USB connection if it isn't: #!/bin/bash # Test communication with UPS if upscmd -l ups > /dev/nul; then echo The UPS is connected. else echo Error: Communication with the UPS has failed! if usbreset "Back-UPS BGM1500 FW:000000G0-313200S9"; then echo USB reset completed successfully. else echo Error: USB reset failed! fi fi Quote Link to comment
Batman Posted August 20, 2022 Share Posted August 20, 2022 For some reason, the name of my UPS (using usbreset) changed to "Back-UPS BGM1500B FW31316S12-31320S10", so the script above stopped working. Since that doesn't seem to be a stable way to reference it, and I couldn't figure out how or if I could use wildcards with usbreset, I modified the script to use lsusb like Gooserhino's: #!/bin/bash # Test communication with UPS if upscmd -l ups > /dev/nul; then echo The UPS is connected. else echo Error: Communication with the UPS has failed! # Get USB path for the UPS APC=$( lsusb | grep "American Power Conversion" | perl -nE "/\D+(\d+)\D+(\d+).+/; print qq(\$1/\$2)") # Test for a USB conection if [ -z "$APC" ]; then echo Error: No USB UPS detected! else echo Resetting the USB connection... # Reset the USB connection if usbreset $APC; then echo USB reset completed successfully. else echo Error: USB reset failed! fi fi fi 1 Quote Link to comment
edmendes Posted January 24 Share Posted January 24 Hi! Great job! On 8/20/2022 at 2:02 PM, Batman said: American Power Conversion But, where I can find this, for my UPS? Thanks! Quote Link to comment
Batman Posted January 25 Share Posted January 25 2 hours ago, edmendes said: Hi! Great job! But, where I can find this, for my UPS? Thanks! In the terminal, use lsusb. It will list the USB devices connected to your server: root@BatRAID:~# lsusb Bus 002 Device 002: ID 8087:8001 Intel Corp. Integrated Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 8087:8009 Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 011: ID 051d:0003 American Power Conversion UPS Bus 003 Device 003: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick Bus 003 Device 009: ID 0c45:0133 Microdia USB Keyboard Bus 003 Device 010: ID 1a86:55d4 QinHeng Electronics 800 Z-Wave Stick Bus 003 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Find the one that corresponds to your UPS, and use that. You don't have to use the whole thing, but it does need to be long enough that it will be the only one that matches. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.