OK, I’ve spent many hours wrestling with this, and I’m sure I’m just missing something fundamental.
I’m having trouble monitoring my UPS after upgrading from an older installation. I’ve installed the NUT add-on and integration, and everything works fine for a while. Sensors report data, but then the connection is lost and my log shows errors about “stale” data.
I am running HA on a Raspberry Pi 3B, with a Cyberpower CP1000PFCLCD attached via a USB cable.
What worked before:
I was running HA on the same Pi with Hassbian; up through HA 0-102-3.
My server setup in /etc/nut/ups.conf:
[cyberpower1]
driver = usbhid-ups
port = auto
desc = "CyberPower CP1000PFCLCD"
pollinterval = 15
and in /etc/nut/upsd.conf:
LISTEN 127.0.0.1 3493
MAXAGE 25
and in /etc/nut/upsd.users:
‘[admin]’
’ password = admin1’
’ actions = SET’
’ instcmds = ALL’
‘[upsmon_local]’
’ password = local1’
’ upsmon master’
and in /etc/nut/nut.conf:
‘MODE=standalone’
My client setup in /etc/nut/upsmon.conf:
‘DEADTIME 25’
‘FINALDELAY 20’
‘MONITOR cyberpower1@localhost 1 upsmon_local local1 master’
This all worked for years with no problems.
Now I have upgraded from scratch with HASS-OS etc. to where I now have running on the same hardware:
Home Assistant OS 5.13
Supervisor 2021-04-0
core 2021.4.4
Network UPS Tools add-on 0.6.2
My configuration for the NUT add-on is:
Options
users:
- username: admin
password: xxx
instcmds:
- all
actions:
- set
devices:
- name: CyberPower1
driver: usbhid-ups
port: auto
config: []
mode: netserver
shutdown_host: 'false'
upsd_maxage: 25
upsd_pollinterval: 15
upsmon_deadtime: 15
upsmon_pollfreq: 5
upsmon_finaldelay: 20
Network
3493
When I start the add-on, the log shows:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] nut: applying...
[fix-attrs.d] nut: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing...
-----------------------------------------------------------
Add-on: Network UPS Tools
Manage battery backup (UPS) devices
-----------------------------------------------------------
Add-on version: 0.6.2
You are running the latest version of this add-on.
System: Home Assistant OS 5.13 (aarch64 / raspberrypi3-64)
Home Assistant Core: 2021.4.4
Home Assistant Supervisor: 2021.04.0
-----------------------------------------------------------
Please, share the above information when looking for help
or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing...
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing...
[14:28:43] INFO: Setting mode to netserver...
[14:28:43] INFO: Generating /etc/nut/upsd.users...
[14:28:43] INFO: Configuring user: admin
[14:28:44] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[14:28:44] INFO: Configuring Device named CyberPower1...
[14:28:45] INFO: Starting the UPS drivers...
Using subdriver: CyberPower HID 0.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Network UPS Tools - UPS driver controller 2.7.4
[cont-init.d] nut.sh: exited 0.
[cont-init.d] nutclient.sh: executing...
[cont-init.d] nutclient.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[14:28:45] INFO: Starting the UPS information server...
0.000000 fopen /var/run/nut/upsd.pid: No such file or directory
0.002598 listening on 0.0.0.0 port 3493
0.004456 Connected to UPS [CyberPower1]: usbhid-ups-CyberPower1
[14:28:46] INFO: Starting the UPS monitor and shutdown controller...
0.000000 fopen /var/run/nut/upsmon.pid: No such file or directory
0.001118 Using power down flag file /etc/killpower
0.001809 UPS: CyberPower1@localhost (master) (power value 1)
0.002153 debug level is '1'
0.002209 Warning: running as one big root process by request (upsmon -p)
0.007045 Init SSL without certificate database
0.059998 Trying to connect to UPS [CyberPower1@localhost]
0.564963 User [email protected] logged into UPS [CyberPower1]
0.066834 Logged into UPS CyberPower1@localhost
so all looks good, and my UPS sensors all work just fine.
But after a while (sometimes minutes, sometimes an hour or so), the UPS is disconnected and the NUT log shows:
794.703949 Data for UPS [CyberPower1] is stale - check driver
795.201832 Poll UPS [CyberPower1@localhost] failed - Data stale
{“message”: “Event nut.ups_event fired.”}Network UPS Tools upsmon 2.7.4
800.204371 Poll UPS [CyberPower1@localhost] failed - Data stale
805.205435 Poll UPS [CyberPower1@localhost] failed - Data stale
810.206516 Poll UPS [CyberPower1@localhost] failed - Data stale
815.207432 Poll UPS [CyberPower1@localhost] failed - Data stale
820.208219 Poll UPS [CyberPower1@localhost] failed - Data stale
825.209106 Poll UPS [CyberPower1@localhost] failed - Data stale
830.209986 Poll UPS [CyberPower1@localhost] failed - Data stale
835.210801 Poll UPS [CyberPower1@localhost] failed - Data stale
840.211556 Poll UPS [CyberPower1@localhost] failed - Data stale
845.212471 Poll UPS [CyberPower1@localhost] failed - Data stale
850.213402 Poll UPS [CyberPower1@localhost] failed - Data stale
855.214360 Poll UPS [CyberPower1@localhost] failed - Data stale
860.221365 Poll UPS [CyberPower1@localhost] failed - Data stale
I’ve been hunting all over the place, and found out this problem seems to be common with many CyberPower products, which reset the USB interface if a driver has not connected for 20 seconds; and NUT is set to consider an UPS “stale” after 15 seconds by default.
The solutions I’ve seen posted all seem to point to possibly some combination of values for maxage, pollinterval, deadtime, and pollfreq; but so far I’ve gotten nowhere. Some combinations seem to fail within several minutes, others take a half hour or so, but all fail. I’ve also seen suggestions of setting a cron job to restart the driver, but that seems like a duct-tape fix.
Has anybody run across this problem (and solved it)?
Thanks!