Imperative UniFi homelab actions the Integration API can't express
Project description
unifictl
Imperative UniFi homelab actions that the official Integration API can't
express. Companion to unifi-mcp (reads):
same gateway, same API key, but unifictl hits the private controller API to
do things — starting with toggling switch-port link aggregation (LACP LAGs).
Status:
set lagimplemented. The first feature works end-to-end against the private controller API (API-key auth). SeeSPEC.mdfor the design anddecisions/for the architecture decision records.
Install
uv tool install unifictl # or: pipx install unifictl
Usage
unifictl set lag off # dissolve the LAGs on the leader ports
unifictl set lag on # restore the LACP bonds
unifictl set lag off --dry-run # print the computed change, apply nothing
A real apply prints the diff, prompts for confirmation, and snapshots the
switch's current port_overrides to a timestamped backup before writing.
Shell completion
unifictl ships bash, zsh, and fish completion. The Homebrew formula installs
it automatically. For uv tool/pipx installs, run:
unifictl completion install # detects your shell from $SHELL
unifictl completion install --shell zsh
Or print a script to wire up manually. For zsh, write it as _unifictl into a
directory on your $fpath — the default is ~/.zfunc:
unifictl completion zsh > ~/.zfunc/_unifictl
# then in ~/.zshrc: fpath+=~/.zfunc && autoload -U compinit && compinit
Completion covers the command tree, set lag on|off, and — when your
controller is reachable — switch MACs (--switch) and port indices
(show port, set lag --leader). A slow or unreachable controller yields no
candidates rather than blocking your shell.
Configuration
Connection and secrets come from the environment or a selected profile (see
Profiles & credentials below); env vars are never committed and take precedence
over profile values. Matching unifi-mcp:
| Variable | Purpose |
|---|---|
UNIFI_BASE_URL |
Gateway address, e.g. https://192.168.1.1 |
UNIFI_API_KEY |
Integration API key (also authenticates the private endpoints) |
UNIFI_SITE |
Controller site (default default) |
UNIFI_CA_CERT |
Optional path to the controller CA certificate (PEM) |
UNIFI_INSECURE_TLS |
Last-resort TLS bypass |
UNIFI_TIMEOUT_MS |
Per-request timeout (default 30000) |
LAG leader ports live in an XDG TOML file at ~/.config/unifictl/config.toml
(leaders = [1, 2]); CLI flags override them. The switch MAC is a profile field
(see below), not a config.toml setting.
Profiles & credentials
Point unifictl at different targets with named profiles. Non-secret config lives
one-file-per-profile under ~/.config/unifictl/profiles/; the API key lives in a
separate ~/.config/unifictl/credentials.toml (0600, the only secret file):
# ~/.config/unifictl/profiles/home.toml (safe to share)
base_url = "https://192.168.1.1"
switch = "aa:bb:cc:dd:ee:ff"
# credential = "default" # which credentials.toml section holds the key
# ~/.config/unifictl/credentials.toml (chmod 600)
[default]
api_key = "…"
A profile's credential defaults to default, so one controller/key backs many
per-switch profiles with no duplication. Select a profile with --profile NAME,
UNIFI_PROFILE, or profile activate NAME (writes default_profile). Fields
resolve CLI > env > profile > built-in; the api_key resolves
UNIFI_API_KEY > credentials[credential] > error.
unifictl profile create home # opens $VISUAL or $EDITOR for the non-secret
# fields, then prompts (hidden) for the API key
unifictl profile list
unifictl profile describe home # fields + redacted key
unifictl profile set home switch aa:bb:cc:dd:ee:ff
unifictl profile activate home
unifictl credential set default # rotate the shared key, once
unifictl credential list
Development
uv sync # create the venv and install deps
task dev:check # lint, format-check, typecheck, import boundaries, tests
task dev:hooks-install # install git hooks (prek)
See SPEC.md for the build reference and decisions/ for the architecture
decision records.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unifictl-0.4.0.tar.gz.
File metadata
- Download URL: unifictl-0.4.0.tar.gz
- Upload date:
- Size: 155.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
594735780ef074c91539d6d5b703e24485e0ecfbf734c931aa44102f9bbee07d
|
|
| MD5 |
38975e26a81446329305b01b279f3743
|
|
| BLAKE2b-256 |
eb4e89a0ee397750f6c7b9e5be9afde4e49425f5e461cab057dff5728570505f
|
Provenance
The following attestation bundles were made for unifictl-0.4.0.tar.gz:
Publisher:
release.yaml on yo61/unifictl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unifictl-0.4.0.tar.gz -
Subject digest:
594735780ef074c91539d6d5b703e24485e0ecfbf734c931aa44102f9bbee07d - Sigstore transparency entry: 2163673905
- Sigstore integration time:
-
Permalink:
yo61/unifictl@6b5e1179de63f2fb0ad075e007e418b7daa6fb85 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yo61
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6b5e1179de63f2fb0ad075e007e418b7daa6fb85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file unifictl-0.4.0-py3-none-any.whl.
File metadata
- Download URL: unifictl-0.4.0-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
354e2f49cdca7d423e27b05306c90929cc953005b4cb6f93bace8537763dfef3
|
|
| MD5 |
367bb42f98e8825be24ee4313f7d3ce6
|
|
| BLAKE2b-256 |
93bb7273f4606af68d61b851d2a5171487cb33a6090111af6bff7336350e4a9d
|
Provenance
The following attestation bundles were made for unifictl-0.4.0-py3-none-any.whl:
Publisher:
release.yaml on yo61/unifictl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unifictl-0.4.0-py3-none-any.whl -
Subject digest:
354e2f49cdca7d423e27b05306c90929cc953005b4cb6f93bace8537763dfef3 - Sigstore transparency entry: 2163673928
- Sigstore integration time:
-
Permalink:
yo61/unifictl@6b5e1179de63f2fb0ad075e007e418b7daa6fb85 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yo61
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6b5e1179de63f2fb0ad075e007e418b7daa6fb85 -
Trigger Event:
push
-
Statement type: