Klaus,
This is actually a known issue and there is also a solution for it.
Ironically the issue is actually known to the AI you were coding with as
well as the solution. But you must understand one critical thing about
AI coding, AI's don't initiate solutions, the programmer must do that.
All the AI does is tag along for the ride.
I've created a LOT of very useful utilities with AI recently and posted
some and have many more that are even cooler that I haven't posted yet.
I have a background in coding although I've never done it as my daily
day job. The thing anyone using AI to code with must understand is that
there actually isn't any Intelligence as us humans understand
intelligence in a parser or LLM. Instead you are dealing with basically
hyperfast lookups. People do not understand just how large the LLMs
dictionaries are. It's trillions of tokens and billions of weights and
the GPUs in the LLM are so fast they can slap all this together in
seconds. Us humans love to anthropomorphize everything and AIs are no
exception. But truly all the AI cares about is the power bill gets paid.
What this means is that if you approach a coding project with a very
explicit idea of how you want it to work then the AI can code it up for
you and it will work really well. You have to basically have the
structure of the tree in your mind all the AI can do is put leaves on
it. You need to know how the boat's going to look the AI can paint it
for you.
But if your idea is to just sort of toss some vague stuff to a coding AI
then it is a crapshoot you might get something usable or you might not.
This is basically how vibe coding works and it's why so much of it is
pure garbage and wanders all over the place.
This does not mean there's not a place for exploration in an AI LLM,
there is and you should do it to get familiar with how it works.
Now looking at your UPS problem here. You have made 2 mistakes here.
The first is assuming that once your Cyberpower UPS stops reporting data
that you can't do anything to boot it in the ass to get it to start
reporting again.
The second is violating the layering of things in modern software.
A few months ago for fun I decided to AI code up a upsd replacement that
hooked into the default USB drivers and I used a really crappy Minuteman
UPS as a sample. This UPS will voluntarily stop sending data for no
reason other than the UPS is being a dick it is very very poor
hardware. It's just like your cyberpower. I discovered this when I was
working with it.
Passing reading times like you are proposing is kicking the can up to
the application. The UPS application is assuming that every piece of
data the USB driver gives it is valid. You want to basically make the
app decide if the data is valid or not instead of just assuming it's
always valid. This puts responsibility on to the app that should be
handled in the driver.
Only the crappiest UPSes like my Minuteman and your Cyberpower have this
randomly going-off-into-lala-land problem. A more expensive UPS does not.
In order to not violate the separation of responsibilities I
experimented with the driver layer - and discovered that with both the
operating system supplied windows UPS USB driver, and the
Canonical-written USB driver for Ubuntu, that those companies had
already identified this problem and had a fix incorporated. The fix is
a 2 part.
First their drivers will refuse to query UPSes over USB too rapidly.
The drivers maintain a state table so if an app too aggressively demands
status or updates, the USB driver just returns the last obtained value
to the app and does not do a new query to the hardware.
second their drivers monitor the UPS and when they see the UPS start
returning stale data they will do a quick detach/attach which is enough
to jar the processor in the UPS back awake.
If you merely assume the driver will always report good data and don't
check it then things "work" If you try to dig deeper into the USB
driver layer then you will notice inconsistencies. When I did that and
started telling the AI my suspicions about some jiggery-pokery going on
with the MS driver then only then did the AI confirm I was right. But
it did not volunteer the information previously because I never asked
that. AI's are stupid.
I don't know how the NUT usb driver is but I would guess it's far
simpler than the Canonical (which is used for their Ubuntu Desktop
Wayland interface to create an icon) or Microsoft one and does not have
the poker in it.
You would never be clued into this if you just tell the AI this is a
problem and solve it for me. You only would be clued into it if you
tell the AI this is the problem and this is how you are gonna solve it
and your solution is already known to the AI.
Ted
On 11/14/2026 4:43 AM, [email protected] wrote:
Hello NUT developers,
docs/nut-names.txt asks for new variable names to be requested on this
list, so I would like to propose one: driver.data.age.
Problem
-------
A client currently cannot tell fresh UPS data from data the driver failed
to refresh. When reads from the device fail or return nothing, the driver
keeps the last value. upsd only reports "Data stale" when the driver itself
stops answering (PING/PONG, MAXAGE). A driver that is alive but gets no data
from the device therefore looks healthy.
I hit this with a CyberPower VP1600ELCD (USB 0764:0501, usbhid-ups, xHCI
host):
- After the HID Report Descriptor was read corrupted at startup (handled in
a separate change), the driver polled nothing usable for about 4 hours.
During that time "upsc" kept showing "ups.status: OL" and
"driver.state: quiet", with no "Data stale".
- With "pollonly", the status report (0x22) failed in about 93% of the
reads, and "upsc" served the last good values without any hint of their
age.
Proposal
--------
Name: driver.data.age
Type: integer, seconds
Meaning: seconds since the driver last obtained data from the device
(or since driver start, if it never did); updated once per
poll loop.
Implementation (branch prepared, PR to follow after this discussion):
- drivers/dstate.c: new dstate_data_received() records the time data was
obtained. By default dstate_dataok() also records it, so every driver
gets an age that matches its existing dstate_dataok() behaviour without
code changes.
- A driver that can tell more precisely calls
dstate_data_received_explicit() once at init and then
dstate_data_received() only when the device really delivered data.
usbhid-ups does this: after a poll in which at least one item was read,
and after an interrupt event that was mapped to a NUT variable.
- drivers/main.c publishes driver.data.age after each upsdrv_updateinfo().
dstate_setinfo() only notifies upsd on change, so a healthy driver
(age 0) causes no extra traffic.
- upsc: when listing all variables ("upsc ups", plain or -j), it prints a
warning to stderr if driver.data.age > 3 * max(pollinterval, pollfreq),
for example:
Warning: UPS data is 95 s old; the driver could not get data from the
device recently. Check the driver log and the connection to the device.
stdout is unchanged except for the one new variable in the listing.
Single-variable queries, -l/-L and -c are unchanged.
What deliberately does not change
---------------------------------
- dstate_dataok()/dstate_datastale(), the "Data stale" logic in upsd, and
driver reconnect behaviour are untouched.
- upsmon does not read the new variable. This is on purpose: upsmon
treats an on-battery UPS that stops communicating as critical and shuts
down, so tying stale semantics to the data age could cause unexpected
shutdowns. The variable is informational only.
- Mixed versions: a new upsc with an old driver sees no variable and prints
no warning; an old upsc with a new driver just lists one more variable.
Questions
---------
1. Is "driver.data.age" acceptable, or would you prefer another name, or
experimental.driver.data.age until the concept settles?
2. Relative seconds versus an absolute timestamp (e.g. ISO 8601, as
nut-names.txt prefers for dates)? I chose relative seconds because they
do not depend on clocks matching between the driver host and the client
host, and they are easy to compare against a threshold.
3. Is the upsc stderr warning welcome, and is 3 * max(pollinterval,
pollfreq) a sensible threshold?
4. Should other drivers be encouraged to opt in to precise reporting, and
should later tools (e.g. upsmon logging, NUT-Monitor) use the value?
Testing so far: make check and make distcheck-light pass; tested on the
hardware above with usbhid-ups (libusb-1.0) on Linux, plus a fake upsd for
the upsc warning cases. Not tested: libusb-0.1, Windows, other drivers and
UPS models.
Disclosure: I prepared the analysis and the code with the help of an AI
coding assistant (Claude Code, model Claude Opus 5.5). I reviewed the
changes and take responsibility for them.
Thanks for your feedback,
Klaus Lenssen
_______________________________________________
Nut-upsdev mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev
_______________________________________________
Nut-upsdev mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev