From 6aee2cebc9fe682c1115dea5211ecd9fb3223631 Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Mon, 30 Mar 2026 02:10:36 +0000 Subject: [PATCH 1/2] docs: align NUT config docs with runtime behavior --- docs/configuration.md | 3 +-- docs/quickstart.md | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 0351e22..e167867 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -35,8 +35,7 @@ The file path where `wolnut` will store its state. This allows the service to re Configuration for connecting to your NUT (Network UPS Tools) server. - `ups`: **(Required)** The name and address of the UPS to monitor. - - **Format**: ``, supports deprecated `@` for backward compatibilty. -- `hostname`: The hostname of the NUT server. Defaults to `localhost`. + - **Format**: `@` (for example: `ups@localhost`). - `port`: The port of the NUT server. Defaults to `3493`. - `username`: The username for authenticating with the NUT server (optional). - `password`: The password for authenticating with the NUT server (optional). diff --git a/docs/quickstart.md b/docs/quickstart.md index 96261ac..fc9dd1f 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -32,9 +32,8 @@ Open `~/wolnut/config.yaml` in your favorite text editor and add the following m nut: # The name of your UPS as defined in your NUT server configuration. - # Format: - ups: "ups" - hostname: "127.0.0.1" # not needed if running localhost/127.0.0.1 + # Format: @ + ups: "ups@localhost" # The directory for the status file should be writable. It will be created if it doesn't exist. status_file: "/config/wolnut_state.json" From 557cc75e4b4c3f6a70f350ad912a47fcd60ce370 Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Mon, 30 Mar 2026 02:46:07 +0000 Subject: [PATCH 2/2] resolve additional documentation issues and remove unused parameters --- config.example.yaml | 2 -- docs/configuration.md | 3 --- docs/quickstart.md | 2 +- tests/test_config.py | 4 ---- wolnut/config.py | 4 ---- wolnut/monitor.py | 11 +---------- 6 files changed, 2 insertions(+), 24 deletions(-) diff --git a/config.example.yaml b/config.example.yaml index be3ae2b..b271b2c 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -3,8 +3,6 @@ log_level: INFO # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL nut: ups: "ups@localhost" # Format: @ - username: "upsmon" # Optional: omit if NUT server doesn't require auth - password: "password" poll_interval: 15 # Poll interval in seconds — should be shorter than the NUT shutdown delay on any client status_file: "/config/wolnut_state.json" # Path to status file, recommended you change this to be outside container if using Docker diff --git a/docs/configuration.md b/docs/configuration.md index e167867..a7f7c13 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -36,9 +36,6 @@ Configuration for connecting to your NUT (Network UPS Tools) server. - `ups`: **(Required)** The name and address of the UPS to monitor. - **Format**: `@` (for example: `ups@localhost`). -- `port`: The port of the NUT server. Defaults to `3493`. -- `username`: The username for authenticating with the NUT server (optional). -- `password`: The password for authenticating with the NUT server (optional). --- diff --git a/docs/quickstart.md b/docs/quickstart.md index fc9dd1f..96ac3a5 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -36,7 +36,7 @@ nut: ups: "ups@localhost" # The directory for the status file should be writable. It will be created if it doesn't exist. -status_file: "/config/wolnut_state.json" +status_file: "/config/wolnut_state.json" clients: - name: "my-pc" diff --git a/tests/test_config.py b/tests/test_config.py index 67d1446..cbb7f37 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -25,9 +25,6 @@ def full_config_dict(): "status_file": "/data/status.json", "nut": { "ups": "myups@nut-server", - "port": 1234, - "username": "monuser", - "password": "monpassword", }, "wake_on": { "restore_delay_sec": 60, @@ -82,7 +79,6 @@ def test_load_config_full(mocker, full_config_dict): assert cfg.poll_interval == 5 assert cfg.status_file == "/data/status.json" assert cfg.nut.ups == "myups@nut-server" - assert cfg.nut.username == "monuser" assert cfg.wake_on.restore_delay_sec == 60 assert cfg.wake_on.min_battery_percent == 50 assert len(cfg.clients) == 2 diff --git a/wolnut/config.py b/wolnut/config.py index bb5f604..b818aff 100644 --- a/wolnut/config.py +++ b/wolnut/config.py @@ -17,10 +17,6 @@ @dataclass class NutConfig: ups: str - port: int = 3493 - timeout: int = 5 - username: str | None = None - password: str | None = None @dataclass diff --git a/wolnut/monitor.py b/wolnut/monitor.py index 9af8763..f0ff858 100644 --- a/wolnut/monitor.py +++ b/wolnut/monitor.py @@ -1,25 +1,16 @@ import subprocess import logging import platform -from typing import Optional logger = logging.getLogger("wolnut") -def get_ups_status( - ups_name: str, username: Optional[str] = None, password: Optional[str] = None -) -> dict: - env = None - - if username and password: - env = {**subprocess.os.environ, "USERNAME": username, "PASSWORD": password} - +def get_ups_status(ups_name: str) -> dict: try: result = subprocess.run( ["upsc", ups_name], capture_output=True, text=True, - env=env, timeout=5, check=False, )