NUT UPS does not trigger lowbattery/shutdown - please help!

(/etc/nut/ups.conf is generated correctly from below file)

/etc/config/nut_server

config driver 'UPS'
	option driver usbhid-ups
	option port auto
	option vendorid 012c
	list override 'battery_charge_low'
	list override 'battery_runtime_low'

config override 'override_battery_charge_low'
	option value '95'
config override 'override_battery_runtime_low'
	option value '5000'

config user
	option username upsuser
	option password upspassword
	option upsmon master

config listen_address
	option address 0.0.0.0
	option port 3493

config upsd 'upsd'
	option statepath /var/run/nut
	option maxconn 1024
	option runas nut

(/etc/nut/upsmon.conf below as you can see is generated wrongly) There are lines in the generated file that are not in /etc/config/nut_monitor

/etc/config/nut_monitor

config upsmon 'UPS'
	option notifycmd '/usr/bin/nut-sendmail-notify'
	list defaultnotify 'EXEC'
	list defaultnotify 'SYSLOG'
	option shutdowncmd /sbin/halt
	option deadtime 15
	option powerdownflags /var/run/killpower
	option onlinemsg "UPS Online"
	option onbattmsg "UPS Power is off"
	option lowbattmsg "UPS battery low"
	option fsdmsg "Router Fsd"
	option comokmsg "Router restored Communications with UPS"
	option combadmsg "Router lost Communications with UPS"
	option shutdowmsg "Router shutting down now"
	option replbattmsg "UPS battery needs changing"

config master
	option upsname 'UPS'
	option hostname 'localhost'
	option username 'upsuser'
	option password 'upspassword'
	option powervalue '1'

/etc/nut/upsmon.conf

RUN_AS_USER nutmon
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/halt"
NOTIFYCMD "/usr/bin/nut-sendmail-notify"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /var/run/killpower
NOTIFYMSG ONLINE "UPS Online"
NOTIFYMSG ONBATT "UPS Power is off"
NOTIFYMSG LOWBATT "UPS battery low"
NOTIFYMSG FSD "Router Fsd"
NOTIFYMSG REPLBATT "UPS battery needs changing"
NOTIFYFLAG ONLINE EXEC+SYSLOG
NOTIFYFLAG ONBATT EXEC+SYSLOG
NOTIFYFLAG LOWBATT EXEC+SYSLOG
NOTIFYFLAG FSD EXEC+SYSLOG
NOTIFYFLAG COMMOK EXEC+SYSLOG
NOTIFYFLAG COMMBAD EXEC+SYSLOG
NOTIFYFLAG SHUTDOWN EXEC+SYSLOG
NOTIFYFLAG REPLBATT EXEC+SYSLOG
NOTIFYFLAG NOCOMM EXEC+SYSLOG
NOTIFYFLAG NOPARENT EXEC+SYSLOG
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
CERTVERIFY 0
FORCESSL 0
MONITOR UPS@localhost 1 upsuser upspassword master

I set the override_battery_charge_low & override_battery_runtime_low to extreme high values to test if the router proceeds with /usr/sbin/halt and killpower to the UPS.
However when attempting to do that, the values of battery_charge_low & battery_runtime_low get reached but does not trigger low battery or shutdown. As you can see below when executing upsc UPS when on battery, it still says ups.status: OB DISCHRG instead of ups.status: OB LB. Can anyone tell me why this happens?

battery.charge: 77
battery.charge.low: 95
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2015/01/10
battery.runtime: 4781
battery.runtime.low: 5000
battery.type: PbAc
battery.voltage: 25.2
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Back-UPS RS 1200G
device.serial: 7C1161V23098  
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.parameter.vendorid: 012c
driver.version: 2.7.4
driver.version.data: APC HID 0.96
driver.version.internal: 0.41
input.sensitivity: medium
input.transfer.high: 294
input.transfer.low: 176
input.transfer.reason: input voltage out of range
input.voltage: 0.0
input.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 322.L1 .I
ups.firmware.aux: L1 
ups.load: 6
ups.mfr: American Power Conversion
ups.mfr.date: 2015/01/10
ups.model: Back-UPS RS 1200G
ups.productid: 0002
ups.realpower.nominal: 720
ups.serial: 7C1161V23098  
ups.status: OB DISCHRG
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 012c

Im not sure if this has anything to do with /etc/nut/upsmon.conf being incorrectly generated?

Also one more thing.
Even though my setup is in netserver mode and the UPS is reporting correctly, when doing upsdrvctl start, i get:

Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Can't claim USB device [012c:0002]: No such file or directory
Driver failed to start (exit status=1)

Does this matter?

OpenWRT 19.07.7
WRT1200ac

Would appreciate your helps. thanks

Ok finally solved it myself.

This was a VERY painful setup from start to finish, trying to smell my fingers to figure out what is actually going on because I mostly followed the official wiki guide here.. https://openwrt.org/docs/guide-user/services/ups/software.nut which mislead me completely, since it is not up-to-date. Indeed NUT will drive you NUTS!

Firstly.
The override options are completely wrong in that guide.
Its supposed to clearly show you how to override for example:
Instead of what i put in my original setup, i had to add:

	list override 'battery_charge_low'      <-------
	list override 'battery_runtime_low'     <-------

config override 'override_battery_charge_low'
	option value '95'
config override 'override_battery_runtime_low'
	option value '5000'

Secondly:
The reason why ups.status didnt trigger ups.status: OB LB so that a shutdown can actually occur, was because i didnt include the option ignorelb
Which wasted a few hours of my life trying to figure out why when putting ignorelb in /etc/config/nut_server did not generate it at all inside /etc/nut/ups.conf, and that was because you had to put: option ignorelb 1 under driver section. The 1, is supposed to "switch it on" apparently. How i found this? i stumbled on the options on Github: https://github.com/openwrt/packages/blob/master/net/nut/files/nut-server.init
Does it show this on the official wiki? no it doesnt.

Finally:
For some reason i removed the option option shutdowncmd '/usr/sbin/nutshutdown' and replaced it with option shutdowncmd '/sbin/halt' in /etc/config/nut_monitor which wasnt actually powering off the UPS. /usr/sbin/nutshutdown was supposed to be explained on the wiki.
Simply like this: /usr/sbin/nutshutdown - A script that checks for powerkill flag and if its there, command is sent to poweroff the UPS and then lastly poweroff the router. OR replace with your own script, if you have a special setup.

/sbin/halt is for shutting down current system, ie. router. which should not plainly be shown in the sample https://openwrt.org/docs/guide-user/services/ups/software.nut#nut_monitor_default_file

Why does this have to be so difficult? Because sadly registrations in editing the wiki are disabled, and no-one will go to great lengths and bother to ask for access either.

I really hope this helps other OpenWRT NUTters in here.

3 Likes

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