Zum Hauptinhalt springen

Network UPS Tools (NUT) Smart-Home-Integration, kostenlos und Open Source

Network UPS Tools (NUT)-Integration für Gladys Assistant

Monitor the status, load and battery runtime of the UPS devices on your NUT servers.

Info

Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.

The Network UPS Tools (NUT) integration lets Gladys retrieve values and states from UPS devices exposed by a reachable NUT upsd server on the local network.

This integration is designed for monitoring. It does not send shutdown, restart, or configuration commands to UPS devices.

Prerequisites​

Your UPS must already work in NUT. From the machine hosting Gladys, the NUT server should answer the following command, after replacing the placeholders with your own values:

upsc <ups-name>@<server-address>

By default, upsd listens on TCP port 3493. Ensure that both network rules and NUT ACLs allow access from Gladys.

Configuration​

  1. Open Integrations, then Network UPS Tools (NUT).
  2. In the Configuration tab, enter the first upsd server; its host is required.
  3. Add up to four additional servers in the optional slots when needed.
  4. For each server, keep port 3493 unless your installation uses another port. Enter NUT credentials when authentication is required.
  5. Choose a refresh interval. The default value of 300 seconds is appropriate for most installations. Gladys polls devices once a minute at most: a longer interval is applied on the closest polling tick.
  6. Save, then use Test NUT connections.

Choosing the refresh interval​

Every published value is kept in the Gladys history, and a UPS exposes up to twelve values. A short interval therefore grows the database quickly: at 60 seconds, a single UPS writes around 17,000 rows per day, against around 3,500 with the default interval of 300 seconds.

To reduce that volume further, the integration only publishes the values that changed since the previous reading; a value that stayed stable is republished at least once an hour so it is never displayed as stale. Go down to 60 seconds only when you need fine-grained monitoring — the remaining runtime during an outage, for instance — and raise the interval up to 86,400 seconds when you would rather spare the database.

Once the connection succeeds, Gladys discovers every UPS returned by the NUT server. Each UPS appears as a distinct Gladys device in discovery. In the Discovery tab, click Add for every UPS you want to integrate: you can add several devices independently. The list is rebuilt on each scan from the NUT LIST UPS command.

Available information​

NUT drivers do not all report the same variables, so the integration only creates sensors for information actually provided by each UPS.

DomainPossible values
BatteryCharge, runtime, voltage, and temperature
PowerInput/output voltage and current
LoadLoad percentage, real power, and apparent power
UPSTemperature, status, and alarms

Values are published only when they are numeric and actually reported by the driver. NUT text statuses are read during communication but are not published as Gladys features, keeping the discovery payload compatible with Core versions that do not yet recognize the text category.

Widget, scenes and actions (Gladys 5.1)​

The integration requires Gladys 5.1 or later.

"UPS" widget​

In Dashboard → Edit → Add a widget, choose UPS, then the UPS to show. The widget displays:

  • the battery charge (gauge) and the remaining runtime;
  • the UPS load and the input voltage;
  • a 24 h chart (battery charge and load);
  • the state (on mains, on battery, low battery…), the NUT alarms, the power and the server;
  • a Refresh button, which reads the UPS right away. It never sends a command to the UPS.

Scene triggers​

In the scene editor, Integrations category:

TriggerWhen
UPS: power failure, on batterythe UPS switches to battery (OB)
UPS: power restoredthe UPS is back on mains (OL)
UPS: battery lowNUT reports a low battery (LB)
UPS: battery to replaceNUT asks for a replacement (RB)
  • Leave the UPS field empty to react to every UPS.
  • The state is checked every minute, whatever the refresh interval: a power cut is seen within a minute.
  • Variables available in the scene: ups_name, status, battery_charge (%), battery_runtime (min), load (%).
  • When the integration starts, the first reading is the reference: no event is sent for a UPS already on battery.

"Read a UPS status" scene action​

It reads the chosen UPS and returns to the following actions: ups_name, status (online, on_battery, low_battery, forced_shutdown, off, bypass, unknown), on_battery, low_battery, replace_battery, battery_charge, battery_runtime (min), load, input_voltage. A reading the UPS does not report is left out.

Example: every morning, read the UPS status then send a message with the remaining runtime.

Troubleshooting​

SymptomRecommended checks
No UPS is foundCheck every host, port, firewall, and that at least one UPS is configured in each ups.conf.
Access or authentication errorCheck the ACLs in upsd.conf and credentials defined in upsd.users.
Some values are missingRun upsc <ups>@<server>; Gladys can only create variables exposed by your NUT driver.
Stale dataA stable value is only rewritten once an hour, which is expected. Beyond that, verify that the NUT driver still communicates with the hardware and inspect the upsd logs.
The Gladys database grows too fastRaise the refresh interval: the amount of history is directly proportional to it. Every UPS you add writes its own history.
Adding a UPS fails with "incomplete or invalid device"Update the integration. That rejection (HTTP 422) came from features published without their min and max bounds, which are now always declared.
Values never change after adding the deviceUpdate the integration: devices are now published with periodic polling enabled.
Some features are displayed without a name or an iconUpdate the integration, then add the UPS again from the Discovery tab so its existing features are updated: the load and the apparent power were published on a category/type pair the Gladys front-end does not know how to draw.
The UPS load is displayed as "Unknown"Update the integration, then add the UPS again from the Discovery tab: the load (ups.load) is now published on a category that lets Gladys show its name, "Load".

For detailed errors, open the integration logs in Gladys. You can also set LOG_LEVEL=debug for more detailed logs.

Resources​

The official NUT network protocol specification details the discovery and read commands used by this integration.

Konfigurationseinstellungen​

Diese Einstellungen fragt Network UPS Tools (NUT) in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
NUT serverssectionNeinConfigure one or more reachable upsd servers. Every UPS exposed by every configured server is discovered as a separate Gladys device.
Server 1 hoststringJaIP address or DNS name of the first NUT upsd server.
Server 1 portnumberNeinThe default NUT TCP port is 3493.
Server 1 username (optional)stringNein
Server 1 password (optional)secretNeinRequired when a username is configured.
Server 2 host (optional)stringNein
Server 2 portnumberNein
Server 2 usernamestringNein
Server 2 passwordsecretNein
Server 3 host (optional)stringNein
Server 3 portnumberNein
Server 3 usernamestringNein
Server 3 passwordsecretNein
Server 4 host (optional)stringNein
Server 4 portnumberNein
Server 4 usernamestringNein
Server 4 passwordsecretNein
Server 5 host (optional)stringNein
Server 5 portnumberNein
Server 5 usernamestringNein
Server 5 passwordsecretNein
Refresh interval (s)numberNeinHow often the readings are written to the Gladys history. Each one is a row in the database: keep 300 s unless you need finer measurements. The UPS status is still checked every minute for the scenes.

So installierst du Network UPS Tools (NUT) in Gladys​

  1. Öffne in Gladys Integrationen: Network UPS Tools (NUT) erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lädt das Docker-Image (ghcr.io/prohand/gladys-nut:2.0.1) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die Oberfläche der Integration (Geräte, Erkennung und Konfiguration).
  3. Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
  4. Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/prohand/gladys-nut.

Network UPS Tools (NUT) benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stündlich aktualisiert, eine neue Version ist also spätestens eine Stunde nach ihrer Veröffentlichung verfügbar.

Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.

Über externe Integrationen​

Network UPS Tools (NUT) ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und führt sie in einer vom Kern isolierten Sandbox aus. Sie wird von prohand veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.

Abonniere den Newsletter von Gladys Assistant

Ein paar E-Mails im Monat zu neuen Releases und Neuigkeiten aus dem Projekt. Verschickt von Pierre-Gilles Leymarie, dem Gründer des Projekts. Jederzeit abbestellbar 🙂