NUT-Driver Stale Data

I am using NUT with the UPS binding. After a while, the Thing goes off line with a message in the UI that the data are stale.

I have NUT running on a Pi 4B running openhabian.

I saw in the log (journalctl -u nut-driver) that it was exiting with Signal 15:


- Boot 922518458229470eb725485ef60a868d --
Jul 31 02:17:46 openhabian-spring4 systemd[1]: Starting Network UPS Tools - power device driver controller...
Jul 31 02:17:46 openhabian-spring4 upsdrvctl[508]: Using subdriver: CyberPower HID 0.4
Jul 31 02:17:46 openhabian-spring4 upsdrvctl[508]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Jul 31 02:17:46 openhabian-spring4 upsdrvctl[508]: USB communication driver 0.33
Jul 31 02:17:46 openhabian-spring4 upsdrvctl[499]: Network UPS Tools - UPS driver controller 2.7.4
Jul 31 02:17:46 openhabian-spring4 usbhid-ups[528]: Startup successful
Jul 31 02:17:46 openhabian-spring4 systemd[1]: Started Network UPS Tools - power device driver controller.
-- Boot 5e4adaf929584a378c3af0aa9efba608 --
Aug 06 06:41:43 openhabian-spring4 systemd[1]: Starting Network UPS Tools - power device driver controller...
Aug 06 06:41:43 openhabian-spring4 upsdrvctl[507]: Using subdriver: CyberPower HID 0.4
Aug 06 06:41:43 openhabian-spring4 upsdrvctl[507]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Aug 06 06:41:43 openhabian-spring4 upsdrvctl[507]: USB communication driver 0.33
Aug 06 06:41:43 openhabian-spring4 usbhid-ups[526]: Startup successful
Aug 06 06:41:43 openhabian-spring4 upsdrvctl[499]: Network UPS Tools - UPS driver controller 2.7.4
Aug 06 06:41:43 openhabian-spring4 systemd[1]: Started Network UPS Tools - power device driver controller.
Aug 09 20:32:15 openhabian-spring4 systemd[1]: Stopping Network UPS Tools - power device driver controller...
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6918]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:32:15 openhabian-spring4 usbhid-ups[526]: Signal 15: exiting
Aug 09 20:32:15 openhabian-spring4 systemd[1]: nut-driver.service: Succeeded.
Aug 09 20:32:15 openhabian-spring4 systemd[1]: Stopped Network UPS Tools - power device driver controller.
Aug 09 20:32:15 openhabian-spring4 systemd[1]: nut-driver.service: Consumed 2min 30.000s CPU time.
Aug 09 20:32:15 openhabian-spring4 systemd[1]: Starting Network UPS Tools - power device driver controller...
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6922]: Using subdriver: CyberPower HID 0.4
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6922]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6922]: USB communication driver 0.33
Aug 09 20:32:16 openhabian-spring4 upsdrvctl[6920]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:32:16 openhabian-spring4 systemd[1]: Started Network UPS Tools - power device driver controller.
Aug 09 20:32:16 openhabian-spring4 usbhid-ups[6924]: Startup successful
Aug 09 20:40:19 openhabian-spring4 systemd[1]: Stopping Network UPS Tools - power device driver controller...
Aug 09 20:40:19 openhabian-spring4 upsdrvctl[8775]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:40:19 openhabian-spring4 usbhid-ups[6924]: Signal 15: exiting
Aug 09 20:40:19 openhabian-spring4 systemd[1]: nut-driver.service: Succeeded.
Aug 09 20:40:19 openhabian-spring4 systemd[1]: Stopped Network UPS Tools - power device driver controller.
Aug 09 20:40:19 openhabian-spring4 systemd[1]: nut-driver.service: Consumed 1.053s CPU time.
Aug 09 20:40:19 openhabian-spring4 systemd[1]: Starting Network UPS Tools - power device driver controller...
Aug 09 20:40:19 openhabian-spring4 upsdrvctl[8779]: Using subdriver: CyberPower HID 0.4

Searching the internet, I suspect this is related to the default MAXAGE setting in upsd.conf of 15 (seconds). I changed it to 25 and will see if that makes a difference.

Taking a different look at syslog, I’m not sure this is the problem, as it seems to recover from the 15 second aging out, but loses connection and fails.

From journalctl | grep upsd


Aug 07 11:34:28 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 11:34:46 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 12:02:24 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 07 12:02:25 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 12:02:42 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 12:30:20 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 07 12:30:21 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 12:30:38 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 12:58:18 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 07 12:58:19 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 12:58:36 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 13:26:14 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 07 13:26:15 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 13:26:32 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 13:54:11 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 07 13:54:12 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 13:54:29 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 14:22:06 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 07 14:22:07 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 07 14:22:24 openhabian-spring4 upsd[543]: Data for UPS [UPS] is stale - check driver
Aug 07 14:50:02 openhabian-spring4 upsd[543]: Send ping to UPS [UPS] failed: Resource temporarily unavailable
Aug 09 20:25:38 openhabian-spring4 sudo[5507]: openhabian : TTY=pts/1 ; PWD=/etc/nut ; USER=root ; COMMAND=/usr/bin/cat upsd.conf
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6918]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:32:15 openhabian-spring4 upsd[543]: Can't connect to UPS [UPS] (usbhid-ups-UPS): Connection refused
Aug 09 20:32:15 openhabian-spring4 upsd[543]: write() failed for ::1: Broken pipe
Aug 09 20:32:15 openhabian-spring4 upsd[543]: write() failed for ::1: Broken pipe
Aug 09 20:32:15 openhabian-spring4 upsd[543]: write() failed for ::1: Broken pipe
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6922]: Using subdriver: CyberPower HID 0.4
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6922]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Aug 09 20:32:15 openhabian-spring4 upsdrvctl[6922]: USB communication driver 0.33
Aug 09 20:32:16 openhabian-spring4 upsdrvctl[6920]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:32:17 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS
Aug 09 20:33:29 openhabian-spring4 sudo[7212]: openhabian : TTY=pts/1 ; PWD=/etc/nut ; USER=root ; COMMAND=/usr/bin/nano upsd.conf
Aug 09 20:40:19 openhabian-spring4 upsdrvctl[8775]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:40:19 openhabian-spring4 upsd[543]: Can't connect to UPS [UPS] (usbhid-ups-UPS): No such file or directory
Aug 09 20:40:19 openhabian-spring4 upsdrvctl[8779]: Using subdriver: CyberPower HID 0.4
Aug 09 20:40:19 openhabian-spring4 upsdrvctl[8779]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Aug 09 20:40:19 openhabian-spring4 upsdrvctl[8779]: USB communication driver 0.33
Aug 09 20:40:20 openhabian-spring4 upsdrvctl[8778]: Network UPS Tools - UPS driver controller 2.7.4
Aug 09 20:40:21 openhabian-spring4 upsd[543]: Connected to UPS [UPS]: usbhid-ups-UPS

After restarting nut-driver (systemctl restart nut-driver), it works for a while:


openhabian@openhabian-spring4:/etc/nut $ upsc ups
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 20
battery.mfr.date: CPS
battery.runtime: 3400
battery.runtime.low: 300
battery.type: PbAcid
battery.voltage: 14.3
battery.voltage.nominal: 12
device.mfr: CPS
device.model: ABST600
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: CyberPower HID 0.4
driver.version.internal: 0.41
input.transfer.high: 140
input.transfer.low: 96
input.voltage: 119.0
input.voltage.nominal: 120
output.voltage: 119.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 11
ups.mfr: CPS
ups.model: ABST600
ups.productid: 0501
ups.realpower.nominal: 360
ups.status: OL
ups.test.result: No test initiated
ups.timer.shutdown: -60
ups.timer.start: 0
ups.vendorid: 0764
openhabian@openhabian-spring4:/etc/nut $

I’m just getting started troubleshooting this and will update this with my progress. I welcome any suggestions.

I wasn’t sure what category to put this in, so I left it blank. I think it is a NUT issue, not a binding issue. But I assume other openhab users will face or have faced similar issues, so I’m sharing my experience.

Continuing the troubleshoot this, it failed again today:
This captures it failing and me restarting nut-driver, which seems to cure the problem temporarily.


openhabian@openhabian-spring4:/etc/nut $ journalctl -u nut-driver
-- Journal begins at Mon 2023-08-14 07:53:18 CDT, ends at Fri 2023-08-18 19:17:01 CDT. --
Aug 18 19:01:12 openhabian-spring4 systemd[1]: Stopping Network UPS Tools - power device driver controller...
Aug 18 19:01:12 openhabian-spring4 upsdrvctl[6926]: Network UPS Tools - UPS driver controller 2.7.4
Aug 18 19:01:12 openhabian-spring4 usbhid-ups[8782]: Parse error on sock: Invalid ctx buffer
Aug 18 19:01:12 openhabian-spring4 usbhid-ups[8782]: Signal 15: exiting
Aug 18 19:01:12 openhabian-spring4 systemd[1]: nut-driver.service: Succeeded.
Aug 18 19:01:12 openhabian-spring4 systemd[1]: Stopped Network UPS Tools - power device driver controller.
Aug 18 19:01:12 openhabian-spring4 systemd[1]: nut-driver.service: Consumed 24min 15.617s CPU time.
Aug 18 19:01:12 openhabian-spring4 systemd[1]: Starting Network UPS Tools - power device driver controller...
Aug 18 19:01:12 openhabian-spring4 upsdrvctl[6928]: Using subdriver: CyberPower HID 0.4
Aug 18 19:01:12 openhabian-spring4 upsdrvctl[6928]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Aug 18 19:01:12 openhabian-spring4 upsdrvctl[6928]: USB communication driver 0.33
Aug 18 19:01:12 openhabian-spring4 upsdrvctl[6927]: Network UPS Tools - UPS driver controller 2.7.4
Aug 18 19:01:12 openhabian-spring4 usbhid-ups[6929]: Startup successful
Aug 18 19:01:12 openhabian-spring4 systemd[1]: Started Network UPS Tools - power device driver controller.
Aug 18 19:04:08 openhabian-spring4 systemd[1]: Stopping Network UPS Tools - power device driver controller...
Aug 18 19:04:08 openhabian-spring4 upsdrvctl[10046]: Network UPS Tools - UPS driver controller 2.7.4
Aug 18 19:04:08 openhabian-spring4 usbhid-ups[6929]: Signal 15: exiting
Aug 18 19:04:08 openhabian-spring4 systemd[1]: nut-driver.service: Succeeded.
Aug 18 19:04:08 openhabian-spring4 systemd[1]: Stopped Network UPS Tools - power device driver controller.
Aug 18 19:04:08 openhabian-spring4 systemd[1]: Starting Network UPS Tools - power device driver controller...
Aug 18 19:04:08 openhabian-spring4 upsdrvctl[10048]: Using subdriver: CyberPower HID 0.4
Aug 18 19:04:08 openhabian-spring4 upsdrvctl[10048]: Network UPS Tools - Generic HID driver 0.41 (2.7.4)
Aug 18 19:04:08 openhabian-spring4 upsdrvctl[10048]: USB communication driver 0.33
Aug 18 19:04:08 openhabian-spring4 upsdrvctl[10047]: Network UPS Tools - UPS driver controller 2.7.4
Aug 18 19:04:08 openhabian-spring4 systemd[1]: Started Network UPS Tools - power device driver controller.
Aug 18 19:04:08 openhabian-spring4 usbhid-ups[10049]: Startup successful

Interestingly, it is still showing 15 even though I changed the max to 25. Perhaps it is a different 15. Or maybe I need to restart more than just nut-driver for it to take effect. Since the file is upsd.conf, I assume it is for nut-driver, so I should be OK.


openhabian@openhabian-spring4:/etc/nut $ sudo cat upsd.conf
# Network UPS Tools: example upsd configuration file
#
# This file contains access control data, you should keep it secure.
#
# It should only be readable by the user that upsd becomes.  See the FAQ.
#
# Each entry below provides usage and default value.

# =======================================================================
# MAXAGE <seconds>
MAXAGE 25
#
# This defaults to 15 seconds.  After a UPS driver has stopped updating
# the data for this many seconds, upsd marks it stale and stops making
# that information available to clients.  After all, the only thing worse
# than no data is bad data.
#
# You should only use this if your driver has difficulties keeping
# the data fresh within the normal 15 second interval.  Watch the syslog
# for notifications

I’m going to try increasing the maxretry in ups.conf and see if that helps (from 3 to 5)


# Set maxretry to 3 by default, this should mitigate race with slow devices:
maxretry = 5


We shall see.

I have a Rule that sends me a message when the status changes to UNDEF. That alerts me to restart nut-driver. If these settings don’t work, I will use the EXEC binding to restart nut-driver, though it is always best to fix the problem rather than using a brute force solution.

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