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 0351e22..a7f7c13 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -35,11 +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`. -- `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). + - **Format**: `@` (for example: `ups@localhost`). --- diff --git a/docs/quickstart.md b/docs/quickstart.md index 96261ac..96ac3a5 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -32,12 +32,11 @@ 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" +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, )