Skip to main content

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 lag implemented. The first feature works end-to-end against the private controller API (API-key auth). See SPEC.md for the design and decisions/ 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

unifictl list devices           # adopted devices and their LAN addresses
unifictl list devices --wan     # add a WAN column; only gateways have one
unifictl list devices --json    # raw controller device objects, for jq

list devices reports LAN addresses throughout. A gateway's public address is its WAN column under --wan; every device behind it shows -.

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 uv:lock to re-lock)
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.

Metadata

Release files for unifictl 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unifictl 0.5.4
File Size Uploaded Provenance Actions
unifictl-0.5.4.tar.gz 188.8 kB With provenance Details for unifictl-0.5.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unifictl 0.5.4
File Interpreter ABI Platform Actions
unifictl-0.5.4-py3-none-any.whl Python 3 none any Details for unifictl-0.5.4-py3-none-any.whl

Total release size: 229.8 kB

Release files / unifictl-0.5.4.tar.gz

Download URL unifictl-0.5.4.tar.gz
Size 188.8 kB
Tags Source
SHA-256 checksum
How to use checksums
785dc7cd5d67ee80f6ad8bc268b863d1b7628661e486e5d17549555d4f8d1694
BLAKE2b-256 checksum
How to use checksums
19040e904c9b397ee9da012a42eea295ec66434d55b1ff53e31fc412134f8e4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release files / unifictl-0.5.4-py3-none-any.whl

Download URL unifictl-0.5.4-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc59746a5ca74594536d0f4bb472664eaf2c442fa181679d1412f91f288802a5
BLAKE2b-256 checksum
How to use checksums
3acd75c8d6ed69bc3ec993b506f7285128580da9f4678ab6f2b2bd59505867e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Security for unifictl 0.5.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for unifictl-0.5.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page