Skip to content

tripplitesu: extend device control and improve command handling - #3722

Open
TomZanna wants to merge 16 commits into
networkupstools:masterfrom
TomZanna:master
Open

TomZanna wants to merge 16 commits into
networkupstools:masterfrom
TomZanna:master

Conversation

@TomZanna

Copy link
Copy Markdown
Contributor

Note on the current state of this PR:
This is an initial draft, and I’m mainly opening it to get some early feedback on the overall structure and approach before spending more time polishing it.

I used Cline with DeepSeek V4 Flash during the development of this work.
I realize that this may eventually be better split into several more focused/atomic commits or separate PRs. I’m happy to restructure it based on maintainer feedback. For now, I preferred to put the work out for review rather than keep polishing it locally indefinitely and risk never submitting it.

Also, please don’t hesitate to use AI to review or summarize the changes if that makes the initial pass easier. Since this is mainly a first-pass review to get feedback on the direction and identify obvious issues, I don’t want to take up more of your time than necessary. Just mention it in the review/PR if AI assistance was used.

  • Added the offdelay and startdelay settings to ups.conf (in seconds and minutes, respectively, matching the units used by the corresponding device commands). Also added support for an optional delay (in seconds) passed through the value argument of the shutdown.return, shutdown.reboot, and shutdown.reboot.graceful instant commands. This allows the delay to be selected per invocation without restarting the driver or changing its configuration.

  • Added control of individual outlet banks through the outlet.n.load.off and outlet.n.load.on instant commands, along with the corresponding outlet.count, outlet.n.status, and outlet.n.switchable variables.

  • Added the shutdown.stayoff instant command and aligned the shutdown-related commands with their intended return-delay behavior:

    • shutdown.reboot and shutdown.reboot.graceful request the load to return immediately after shutdown. The device will only restart the load when the restart delay is longer than the shutdown delay.
    • shutdown.return and shutdown.stayoff clear the return delay, so the load returns only when mains is (re)applied, or remains off, respectively.
  • Added the following variables and instant commands:

    • Read/write variables: ups.beeper.status, ups.delay.start, ups.start.auto, ups.watchdog.status, outlet.delay.start, and input.eco.switchable
    • Read-only variable: battery.date
    • Instant commands: beeper.mute and clear.fault.record
    • Added validation of input.transfer.low and input.transfer.high against the ranges reported by the device, exposed through input.transfer.low.min/.max and input.transfer.high.min/.max.
  • Instant commands and variable writes now report failures when the device rejects an operation or does not respond, instead of unconditionally reporting success.

  • Added the command_delay setting to ups.conf to enforce a minimum interval, in milliseconds, between commands sent to the UPS. This works around devices that fail to respond when commands are sent too soon after one another. The interval is measured from the previous command, so an idle connection is not penalized. The special value -1 starts the driver without an initial delay and enables one-second command pacing only after a command times out. See [PR drivers/tripplitesu.c: add 1s delay in command_send #3273].

Add the optional 'value' argument to the upscmd man page synopsis
and describe both the 'command' and 'value' parameters.

Signed-off-by: TomZanna <git@tomzanna.com>
Document and implement command_delay automatic timeout handling, plus
offdelay and startdelay parameters, and expose outlet.count and
ups.watchdog.status variables.

Signed-off-by: TomZanna <git@tomzanna.com>
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit e0eaba0 is temporarily available: NUT-tarballs-PR-3722.zip.

…ings

Add read-only input.transfer.reason variable from the device's recorded
bypass code, refreshed each poll and cleared by clear.fault.record. Stop
publishing device settings (outlet.delay.start, ups.start.auto,
ups.watchdog.status, input.eco.switchable, ups.beeper.status) with assumed
defaults; expose them only once the device reports them, retaining last
known values with a warning when the device stops responding.
@jimklimov jimklimov added Tripp Lite Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved AI For good or bad, machine tools are upon us. Humans are still the responsible ones. labels Oct 2, 2026

@jimklimov jimklimov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks quite solid, thanks! One group of comments I have is about terminology (see concerns about "outlet bank" below), another is about readability of logged messages - many places where I think there should be a space between %s tokens... or maybe I missed something as I read the code. There may also be some de-duplication possible with existing common code.

Comment thread docs/man/tripplitesu.txt Outdated
Comment thread docs/man/tripplitesu.txt Outdated
Comment thread docs/man/upscmd.txt
Comment thread drivers/tripplitesu.c Outdated
Comment thread drivers/tripplitesu.c Outdated
Comment thread drivers/tripplitesu.c Outdated
Comment thread drivers/tripplitesu.c Outdated
Comment thread drivers/tripplitesu.c Outdated
Comment thread drivers/tripplitesu.c Outdated
Comment thread drivers/tripplitesu.c Outdated
@jimklimov jimklimov added this to the 2.8.6 milestone Oct 2, 2026
…y in man page

Improve tripplitesu driver error handling to exit upon intermediate
errors rather than continuing. Update the man page to consistently use
"outlet" terminology instead of "outlet bank", and expand documentation
of the watchdog setting and command failure behavior for clarity.

Signed-off-by: TomZanna <git@tomzanna.com>

@jimklimov jimklimov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better, thanks for the previous changes. Got a comment/suggestion on watchdog feature, see below.

Comment thread docs/man/tripplitesu.txt
@TomZanna

TomZanna commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

I found something I'd like your opinion on before changing it.

The shutdown.* commands are a sequence of writes: ARB (set auto-reboot so the load comes back on), SDR (the return delay) and finally SDA (which actually schedules the shutdown). As of now, the code never stops at the first failure. Each step marks the result STAT_INSTCMD_FAILED and execution continues, so SDA (the power-off) is sent even when setting ARB=1 (the thing that guarantees the load comes back) has failed.

This might be fine for shutdown.stayoff (where staying off is desired, even if it might unexpectedly power back on), but for shutdown.return / shutdown.reboot / shutdown.reboot.graceful, it can accidentally leave the load dead.

I'd like to gate the final SDA on the "will come back on" prerequisites, and abort before powering off (returning STAT_INSTCMD_FAILED and leaving the load powered) when they fail. The trade-off is the shutdown.default path called by upsmon/upsdrvctl on low battery: aborting means the machine stays up until the battery dies (losing the clean shutdown), while proceeding keeps the power-cycle intent but accepts the risk of a load that does not come back.

So: for the automatic shutdown, would you rather have it abort when the return cannot be guaranteed, or threat the whole sequence as "best-effort" (attempt ARB/SDR, log a warning if they fail, but still issue SDA)?

@jimklimov

Copy link
Copy Markdown
Member

That's quite a loaded question :) A loud log at this stage would likely not be seen (unless someone is actively troubleshooting at that moment), nor recorded (if this happens in nutshutdown or similar end-game handler, after filesystems are off.

Maybe add a driver configuration toggle for this situation, with whichever default, so it would act according to that.

TomZanna and others added 2 commits October 13, 2026 17:07
Expose the watchdog timeout and restart-alarm fields as the read/write
ups.watchdog.timeout and ups.watchdog.alarm variables, add a reset.watchdog
instant command, and disarm an armed watchdog when the driver exits on
purpose so that a restart (e.g. during a package upgrade) does not power
cycle the load. Watchdogs the driver never enabled or that are already
disabled are left untouched, and a crash or SIGKILL does not disarm them.

Make shutdown.default always turn auto-reboot on so every outlet comes back
when mains returns, and add the shutdown_mode setting to choose between
stopping at the first failed or unanswered operation (abort) and continuing
(best effort, default). It no longer sets a return delay of its own, so
startdelay only seeds ups.delay.start. The load.off/load.on multi-frame
commands now also stop at the first rejected or unanswered frame.

Signed-off-by: TomZanna <git@tomzanna.com>
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 18, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 21, 2026
Rework the tripplitesu manual to match the driver's current behavior:
document the accepted ranges for command_delay, offdelay and startdelay,
clarify which instant commands use each delay, and drop the removed -1
automatic mode of command_delay along with the historical shutdown delay
default that no longer applies.

Signed-off-by: TomZanna <git@tomzanna.com>
Extend the auto-reboot reader into a generic helper driven by a table
of protocol command, variable name, log description and on/off names.
Use it for auto-reboot, ECO mode and buzzer settings, removing the
duplicated polling, parsing and warning code from each getter.

Signed-off-by: TomZanna <git@tomzanna.com>
Replace the separate low/high transfer voltage getters and setters with
table-driven, index-based helpers backed by a transfer_voltage_id enum.
Each entry carries the dstate variable name and its field in the TXV
reply, so field parsing, comparison and the combined device write share
one code path instead of duplicated logic.

Store reported transfer limits per voltage in arrays keyed by the same
enum, replacing the four min/max globals.

Signed-off-by: TomZanna <git@tomzanna.com>
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 21, 2026
Move the shutdown command lookup to the top of instcmd() so these
commands are matched before the outlet and simple command paths. Guard
the outlet command walk and the shutdown lookup with a case-insensitive
prefix check, so commands that cannot match skip those loops entirely.

Also shorten several header and function comments and drop the verbose
restore hint from the ups.start.auto change log line, keeping only the
old and new setting names.

Signed-off-by: TomZanna <git@tomzanna.com>
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 22, 2026
The tripplitesu device restarts its watchdog timer on every command,
not only on an explicit kick, so the driver's periodic polls usually keep
an armed watchdog quiet. However, a watchdog that trips, power cycles the
load and comes back disabled could previously go unnoticed, leaving stale
values in `ups.watchdog.status`, `ups.watchdog.timeout` and
`ups.watchdog.alarm`.

- Re-read the watchdog setting on every update cycle while the watchdog
  is believed to be armed, so a trip is published even when the driver
  keeps running across the restart (e.g. host not powered by the UPS).
- Log repeated failed reads at debug level to avoid flooding the log,
  and log other failed setting reads instead of silently using defaults.
- Document that polls restart the timer as an implementation detail, why
  an explicit `reset.watchdog` is still recommended, and that
  `reset.watchdog` fails after a trip until the watchdog is re-armed.
- Add corresponding `NEWS.adoc` entries for the upcoming release.

Signed-off-by: TomZanna <git@tomzanna.com>
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 22, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 22, 2026
@TomZanna
TomZanna marked this pull request as ready for review October 22, 2026 20:07
Add a `ups.start` instant command so a device that has been switched
off can be started again. It enables the auto-reboot setting and writes
the restart delay, which is what makes the firmware start its outputs.
The delay is passed as the command value in whole minutes (0-60) and
defaults to the `startdelay` setting when no value is given. A device
that is already running is not switched off; only the delay is stored,
and a scheduled shutdown is left untouched.

The command fails when the device does not confirm the auto-reboot
setting, before anything that could change the power state is sent.
Document the command in the tripplitesu(8) man page, add its entry to
`data/cmdvartab`, and note it in NEWS.adoc.

Signed-off-by: TomZanna <git@tomzanna.com>
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 25, 2026
@github-actions github-actions Bot deleted a comment from AppVeyorBot Oct 25, 2026
@AppVeyorBot

Copy link
Copy Markdown

✅ Build nut 2.8.5.5909-master completed (commit b05c3d7c90 by @TomZanna)

@TomZanna
TomZanna requested a review from jimklimov October 26, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI For good or bad, machine tools are upon us. Humans are still the responsible ones. Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved Tripp Lite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants