<div dir="auto">First of all, I agree that technical discussions should not devolve into personal, political, ageist, experienceist etc. off-topics and overt or concealed insults. We are all adults here, I suppose - let's behave like that. Non-adults are welcome to learn if needed, or present the finer sides of their personality too ;)<div dir="auto"><br></div><div dir="auto">Surely, the discussions are here to share opinions and knowledge, perhaps to teach and learn too, but this can all be done in a civilized manner. Even by semi-asocial geeks posting from a bat-cave, those like myself at times. Soft skills are learnable like most others ;P<br><div dir="auto"><br></div><div dir="auto">> <span style="background-color:rgb(250,248,255);font-size:12.8px">In particular, I would recommend an explicit per-driver option to disable the use of stale cached data. In that mode, the information must be fresh; if fresh data cannot be obtained, the driver must clearly report that failure instead of presenting an old value as a current measurement. I mean disabling the use of stale values, not disabling the indication of their age or the reporting of a communication failure.</span></div><div dir="auto"><br></div><div dir="auto">As noted earlier, this is neigh impossible. Setting aside how frequently the device itself learns of its internal state in digital form (upon protocol request or cached in the controller so literally same data is returned by polling that device within some timeframe), we have one program on the computer side getting that data (age=0 if you like) and another loop consuming and acting on it - whether in same program (mono driver/app) or another program or even computer (NUT driver/server/client).</div><div dir="auto"><br></div><div dir="auto">Maybe if your mono-app polls the device and immediately acts upon each reading it sensed, you could assume age=0 as a required constraint. Even if in one program you read and parse all there is first, deduce data and actions later (e.g. estimate runtime from fresh readings charge, load, time on-battery etc.), by the time you act the age is already not zero-ish. With more data-relaying components and devices in play, more so.</div><div dir="auto"><br></div><div dir="auto">So we can just hope to track how much above zero that age is - microseconds or minutes, and how much is acceptable (as noted in the thread, driver might announce that).</div><div dir="auto"><br></div><div dir="auto">As also noted, with protocols that do not surely update the whole device data snapshot simultaneously and atomically, you can well see vastly different ages for various readings. You can also consider different max ages as problematic, to the point of only reading some once in a driver's uptime or very rarely (status vs. battery installation date).</div><div dir="auto"><br></div><div dir="auto">> I would like drivers to be able to report "unavailable" for a value, and drivers should manage timeouts (that they understand because it's device behavior) and report them as unavailable.</div><br>> If the driver stops communicating, upsd should set everything to unavailable. </div><div dir="auto"><br><div dir="auto">At least the second point should be here already, unless development of past months disrupted it again: when drivers detect they should reconnect, they should declare datastale first and also update the driver state to "reconnecting". There was certainly a PR for that in the recent year or so; maybe developer docs were not updated to require that for new change sets - should check on that bit.</div><div dir="auto"><br></div><div dir="auto">Looking at `drivers/dstate.c` I see `vdstate_setinfo()` posting SETINFO on the driver-server socket/pipe for each single written entry, so `upsd` can update its cached view (and its per-entry timestamp) as soon as each NUT-named data point is parsed and saved by the driver internally. The counterpart can be seen in `server/sstate.{c,h}` and in `common/state.c` for foundations of both.</div><div dir="auto"><br></div><div dir="auto">* "`upsd` can" means it is able to do so, as soon as its file descriptor walking loop gets that line, although many events along the way may delay this.</div><div dir="auto"><br></div><div dir="auto">Note that clocks between computers are never in precise sync, and may be not monotonous in one computer either. (There are recent PRs to employ system-provided monotonous clock readings where available.) So `upsd` is IMHO a good point as the cacher and provider of data points to be an authority about their age, at least in its view. It also does track already when the UPS driver last talked on the bus, see MAXAGE setting.</div><div dir="auto"><br></div><div dir="auto">Ages seen in drivers dstate, or in long-running clients that regularly grab snapshots over networked protocol may differ.</div><div dir="auto"><br></div><div dir="auto">There is certainly some code to walk those state trees for "data older than X", but I can't say OTOH where it is used already and what usages might get added due to e.g. this discussion.</div><div dir="auto"><br></div><div dir="auto">Hope this helps,</div><div dir="auto">Jim Klimov</div><div dir="auto"><br></div><div dir="auto">PS: No AI here, fingers hurt after typing this on painted keyboard shim of a phone for an hour while commuting.</div></div><br><br><div class="gmail_quote gmail_quote_container" dir="auto"><div dir="ltr" class="gmail_attr">On Mon, Nov 16, 2026, 13:55 Greg Troxel via Nut-upsdev <<a href="mailto:nut-upsdev@alioth-lists.debian.net">nut-upsdev@alioth-lists.debian.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Edgar Fuß via Nut-upsdev <<a href="mailto:nut-upsdev@alioth-lists.debian.net" target="_blank" rel="noreferrer">nut-upsdev@alioth-lists.debian.net</a>> writes:<br>
<br>
> Isn't the most interesting information not how old some data is, but how long it's overdue (taking into account the peculiarities of this specific hardware)?<br>
<br>
Agreed. There are multiple ways for measurements to flow from the UPS<br>
unit to upsd, and as a user of upsd (via upsc or the protocol) I would<br>
like not to care about those details.<br>
<br>
> OTOH, my feeling is that most of this how-long-is-that-data-stale<br>
> logic belongs into upsd, not into each individual driver. (And<br>
> deciding whether a certain data being stale for a certain time is a<br>
> problem belongs into the application: I can live with not knowing when<br>
> it will be time to replace the battery for much longer than with not<br>
> knowing whether I'm on battery.)<br>
<br>
To me the key point is that when a driver makes a report, that report<br>
should only include information which is "not stale", with some<br>
acceptable fuzz for values that are read less frequently. And then upsd<br>
should convey "how long since the last (non-stale) report". I see this<br>
as pretty straightforward conceptually.<br>
<br>
> So, what about the driver, at initialization time, telling upsd, for each value, what the expected update interval is (with upsd chosing a default for the majority of them) and having upsd deal with the rest?<br>
> Of course, there should be an additional method for the driver to tell upsd that reading a value failed by providing an "undefined" value.<br>
<br>
I always lean to the simplest reasonable approach. Here,<br>
<br>
I would like drivers to be able to report "unavailable" for a value,<br>
and drivers should manage timeouts (that they understand because it's<br>
device behavior) and report them as unavailable.<br>
<br>
If the driver stops communicating, upsd should set everything to<br>
unavailable. Timeout here could be 5s by spec, and drivers that are<br>
up and functioning and have no news can just keepalive to avoid this<br>
timeout. This would matter only for a driver crash.<br>
<br>
which is mostly what you said, but not pushing timeouts to upsd.<br>
<br>
<br>
Separately, I would suggest that with a driver reading from a UPS unit,<br>
things are either<br>
<br>
ok, where all values can be read routinely<br>
<br>
not ok, where some values that should work give errors<br>
<br>
and we should not agonize over shades of grey of not ok, and let drivers<br>
decide which side of the boundary they are on. To me the things that<br>
really matter and the timescales I care about them are<br>
<br>
input voltage - ok or bad: immediate<br>
online or on battery: a few seconds<br>
battery voltage or remaining runtime: 30s<br>
<br>
output VA: nice to have a few seconds, every minute is acceptable<br>
<br>
battery needs replacement: 1h<br>
<br>
<br>
_______________________________________________<br>
Nut-upsdev mailing list<br>
<a href="mailto:Nut-upsdev@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsdev@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev</a><br>
</blockquote></div></div>