Skip to content

sysutils/nut: support multiple UPS devices#5542

Open
toreamun wants to merge 1 commit into
opnsense:masterfrom
toreamun:nut-multiple-ups
Open

sysutils/nut: support multiple UPS devices#5542
toreamun wants to merge 1 commit into
opnsense:masterfrom
toreamun:nut-multiple-ups

Conversation

@toreamun

@toreamun toreamun commented Jul 9, 2026

Copy link
Copy Markdown

Important notices

Before you submit a pull request, we ask you kindly to acknowledge the following:

If AI was used, please disclose:

  • Model used: Claude
  • Extent of AI involvement: implementation drafted with AI assistance, reviewed and tested by me on real hardware (two USB HID UPS devices)

Describe the problem

The plugin only supports a single UPS: the model has one enable flag per driver type and a single global UPS name. NUT itself handles any number of devices. Enabling more than one driver today even generates a broken ups.conf (duplicate sections with the same name), so there is no way to monitor for example two USB HID devices on the same box.


Describe the proposed solution

Replace the per-driver sections in the model with a list of UPS devices (name, driver, power value, arguments), shown as a grid on the settings page. The ups.conf and upsmon.conf templates loop over the list, SHUTDOWNCMD/POWERDOWNFLAG are emitted once, and each MONITOR line gets a configurable power value so a UPS that does not feed this system can be set to monitoring only (0). The netclient section gets its own name field instead of borrowing the global one.

A model migration (1.0.4 -> 1.1.0) converts existing configurations: the enabled driver section becomes the first row in the list, keeping name and arguments (apcupsd hostname/port become a port argument). I verified that an existing setup produces identical ups.conf/upsmon.conf after migrating.

The diagnostics page and the dashboard widget now show status per UPS. While testing this I found that upsc from NUT 2.8.5 segfaults on FreeBSD 14.3 (networkupstools/nut#3454), which left the status page and widget empty regardless of this change, so the status action now reads the variables directly from upsd instead of shelling out to upsc (same output format).

Tested on OPNsense 26.1.11 with an APC Back-UPS ES 700 and an Eaton 3S (both usbhid-ups), including migration from os-nut 1.9_1, editing and toggling devices from the grid, and upsd/upsmon picking up both devices.


Related issue

None.

The model gets a list of UPS devices (name, driver, power value,
arguments) instead of one enable flag per driver, shown as a grid on
the settings page. A migration converts existing configurations.

The status page and dashboard widget show all devices and now read
the variables directly from upsd, since upsc from NUT 2.8.5 segfaults
on FreeBSD 14.3 (networkupstools/nut issue 3454).
@toreamun
toreamun force-pushed the nut-multiple-ups branch from 9d2c91f to 4914d49 Compare July 9, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant