<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Hmm, looking at status_commit(), if the UPS actually reported just “OB", but the “ignorelb” logic kicked in, wouldn’t status_commit() change it to “OB LB”? And would clients interpret that correctly?</div><div><br class=""></div><div>And, assuming status_commit() <i class="">is</i> called, is the status so saved what’s returned on a future client query? <br class=""><br class="">I’m really unsure how all of this works. I don’t suppose there’s some kind of “general flow of information” documentation somewhere?</div><div><br class=""></div><div><blockquote type="cite" class="">On May 24, 2023, at 4:26 AM, Carsten Aulbert <<a href="mailto:carsten.aulbert@aei.mpg.de" class="">carsten.aulbert@aei.mpg.de</a>> wrote:<br class=""><br class="">Hi again,<br class=""><br class="">On 5/22/23 18:31, Willcox David via Nut-upsuser wrote:<br class=""><blockquote type="cite" class="">Hmm. Is there maybe something there already that will do this? Maybe kind of back-handed.<br class="">In drivers/dstate.c, I see:<br class="">1. In status_init(), if “driver.flag.ignorelb” is set in the driver<br class="">   state, the “ignorelb” flag is set.<br class="">2. In status_set(), if ignorelb is set, and the status being set<br class="">   (presumably from the UPS) is LB, it’s ignored. In other words, LB<br class="">   reported by the UPS is ignored.<br class="">3. In status_commit(), if ignorelb is set, there’s code to compare<br class="">   battery.charge against battery.charge.low and battery.runtime<br class="">   against battery.runtime.low. If either is below the “low” setting, “<br class="">   LB” is added to the status. (So “OL” would become “OL LB” and “OB"<br class="">   would become “OB LB”. And note that the two “.low” settings can be<br class="">   overridden in the config.<br class=""></blockquote><br class="">this looks exactly like the right place and functionality I would like to have, BUT<br class=""><blockquote type="cite" class="">Am I missing something?<br class=""></blockquote><br class="">yes, probably the same trap I fell into, status_commit does not seem to be not called (at least from the dummy driver I use for testing) upon changing charge/runtime. I can only force a call by flipping OL/OB.<br class=""><br class="">I sprinkled a bit of debug information [1] into status_commit and journald looks like<br class=""><br class="">initial upsrw call to set dummy OL:<br class=""><br class="">May 24 08:23:24 gateway dummy-ups[284580]: [D2] entering setvar(ups.status, OL)<br class="">May 24 08:23:24 gateway dummy-ups[284580]: [D2] status_commit: Entering (1)<br class="">May 24 08:23:24 gateway dummy-ups[284580]: [D2] status_commit: charge val/low 33/30']<br class="">May 24 08:23:24 gateway dummy-ups[284580]: [D2] status_commit: runtime val/low 200/180']<br class="">May 24 08:23:27 gateway dummy-ups[284580]: [D1] upsdrv_updateinfo...<br class=""><br class="">setting it OB<br class=""><br class="">May 24 08:23:38 gateway dummy-ups[284580]: [D2] entering setvar(ups.status, OB)<br class="">May 24 08:23:38 gateway dummy-ups[284580]: [D2] status_commit: Entering (1)<br class="">May 24 08:23:38 gateway dummy-ups[284580]: [D2] status_commit: charge val/low 33/30']<br class="">May 24 08:23:38 gateway dummy-ups[284580]: [D2] status_commit: runtime val/low 200/180']<br class="">May 24 08:23:42 gateway dummy-ups[284580]: [D1] upsdrv_updateinfo...<br class=""><br class="">changing run-time<br class=""><br class="">May 24 08:23:48 gateway dummy-ups[284580]: [D2] upsdrv_updateinfo: NO-OP: input file was already read once to the end<br class="">May 24 08:23:49 gateway dummy-ups[284580]: [D2] entering setvar(battery.runtime, 100)<br class="">May 24 08:23:52 gateway dummy-ups[284580]: [D1] upsdrv_updateinfo...<br class=""><br class="">later changing charge<br class=""><br class="">May 24 08:37:28 gateway dummy-ups[284580]: [D2] send_to_one: sending PONG<br class="">May 24 08:37:32 gateway dummy-ups[284580]: [D1] upsdrv_updateinfo...<br class="">May 24 08:37:33 gateway dummy-ups[284580]: [D2] upsdrv_updateinfo: NO-OP: input file was already read once to the end<br class="">May 24 08:37:33 gateway dummy-ups[284580]: [D2] entering setvar(battery.charge, 5)<br class="">May 24 08:37:37 gateway dummy-ups[284580]: [D1] upsdrv_updateinfo...<br class="">May 24 08:37:38 gateway dummy-ups[284580]: [D2] upsdrv_updateinfo: NO-OP: input file was already read once to the end<br class=""><br class="">and still no LB.<br class=""><br class="">But going back "OL", suddenly LB is added:<br class=""><br class="">May 24 09:21:48 gateway dummy-ups[284580]: [D2] entering setvar(ups.status, OL)<br class="">May 24 09:21:48 gateway dummy-ups[284580]: [D2] status_commit: Entering (1)<br class="">May 24 09:21:48 gateway dummy-ups[284580]: [D2] status_commit: charge val/low 5/30']<br class="">May 24 09:21:48 gateway dummy-ups[284580]: [D2] status_commit: appending LB flag [charge '5' below '30']<br class=""><br class="">Thus it seems somewhere in the state logic there ought to be a possibility to trigger this automatically (on changing charge/runtime while OB) but there is not.<br class=""><br class="">Hopefully, someone with more knowledge than I have can chime in here :)<br class=""><br class="">Cheers<br class=""><br class="">Carsten<br class=""><br class="">[1] Please don't judge me by this, I still use printf and friends a lot for debugging (sorry for breaking lines, it's just for illustration):<br class=""><br class="">@@ -1113,12 +1116,13 @@<br class="">/* write the status_buf into the externally visible dstate storage */<br class="">void status_commit(void)<br class="">{<br class="">+       upsdebugx(2, "%s: Entering (%d)", __func__, ignorelb);<br class="">       while (ignorelb) {<br class="">               const char      *val, *low;<br class=""><br class="">               val = dstate_getinfo("battery.charge");<br class="">               low = dstate_getinfo("battery.charge.low");<br class="">-<br class="">+               upsdebugx(2, "%s: charge val/low %s/%s']", __func__, val, low);<br class="">               if (val && low && (strtol(val, NULL, 10) < strtol(low, NULL, 10))) {<br class="">                       snprintfcat(status_buf, sizeof(status_buf), " LB");<br class="">                       upsdebugx(2, "%s: appending LB flag [charge '%s' below '%s']", __func__, val, low);<br class="">@@ -1127,6 +1131,7 @@<br class=""><br class="">               val = dstate_getinfo("battery.runtime");<br class="">               low = dstate_getinfo("battery.runtime.low");<br class="">+               upsdebugx(2, "%s: runtime val/low %s/%s']", __func__, val, low);<br class=""><br class="">               if (val && low && (strtol(val, NULL, 10) < strtol(low, NULL, 10))) {<br class="">                       snprintfcat(status_buf, sizeof(status_buf), " LB");<br class=""><br class=""><br class=""><br class="">-- <br class="">Dr. Carsten Aulbert, Max Planck Institute for Gravitational Physics,<br class="">Callinstraße 38, 30167 Hannover, Germany, Phone +49 511 762 17185<br class="">_______________________________________________<br class="">Nut-upsuser mailing list<br class=""><a href="mailto:Nut-upsuser@alioth-lists.debian.net" class="">Nut-upsuser@alioth-lists.debian.net</a><br class="">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser<br class=""></blockquote><br class=""></div></body></html>