unifi-network-maps
CLI tool for generating UniFi network maps from LLDP topology. Outputs Mermaid, SVG (including isometric), Markdown, and MkDocs formats. Built on the unifi-topology library for topology modeling and SVG rendering.
Python 3.12+ is supported (3.13 preferred).
Installation
PyPI:
pip install unifi-network-maps
From source:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-build.txt
pip install .
Configuration
Set environment variables (no secrets in code). The CLI loads .env automatically if present:
export UNIFI_URL=https://192.168.1.1
export UNIFI_SITE=default
export UNIFI_USER=local_admin
export UNIFI_PASS=********
export UNIFI_VERIFY_SSL=false
export UNIFI_REQUEST_TIMEOUT_SECONDS=10
Use a custom env file:
unifi-network-maps --env-file ./site.env --stdout
Quickstart
Basic map (tree layout by LLDP hops):
unifi-network-maps --stdout
Write Markdown for notes tools:
unifi-network-maps --markdown --output ./network.md
Usage
Show ports + clients:
unifi-network-maps --include-ports --include-clients --stdout
SVG output (orthogonal layout + icons):
unifi-network-maps --format svg --output ./network.svg
Isometric SVG output:
unifi-network-maps --format svg-iso --output ./network.svg
MkDocs output (ports included, no clients):
unifi-network-maps --format mkdocs --output ./docs/unifi-network.md
MkDocs output with clients:
unifi-network-maps --format mkdocs --include-clients --output ./docs/unifi-network.md
MkDocs output with dual Mermaid blocks for Material theme switching:
unifi-network-maps --format mkdocs --mkdocs-dual-theme --output ./docs/unifi-network.md
LLDP tables for troubleshooting:
unifi-network-maps --format lldp-md --output ./lldp.md
Legend only:
unifi-network-maps --legend-only --stdout
JSON payload (devices + clients + VLAN inventory):
unifi-network-maps --format json --output ./payload.json
Home Assistant integration
The live Home Assistant integration (Config Flow + coordinator + custom card) lives in a separate repo:
Programmatic API
The topology model, diff engine, snapshot serialization, and SVG renderer live in the unifi-topology library. Use it directly for programmatic access:
from unifi_topology.model.topology import Topology
from unifi_topology.render import render_svg
See the unifi-topology documentation for the full API.
Examples (mock data)
These examples are generated from examples/mock_data.json (safe, anonymized fixture).
Mock generation requires dev dependencies (pip install -r requirements-dev.txt -c constraints.txt).
Regenerate the fixture + SVG with make mock-data.
Generate mock data (dev-only, uses Faker):
unifi-network-maps --generate-mock examples/mock_data.json --mock-seed 1337
Generate the isometric SVG:
unifi-network-maps --mock-data examples/mock_data.json --include-ports --include-clients --format svg-iso --output examples/output/network_ports_clients_iso.svg
Themes & Icon Sets
Built-in themes (--theme) and icon sets (--icon-set) can be combined freely.
Regenerate this overview with make theme-matrix.
Mermaid example with ports:
graph TB
core_switch["Core Switch"] ---|"Core Switch: Port 7 (AP Attic) <-> AP Attic: Port 1 (Core Switch)"| ap_attic["AP Attic"];
core_switch["Core Switch"] ---|"Core Switch: Port 3 (AP Living Room) <-> AP Living Room: Port 1 (Core Switch)"| ap_living_room["AP Living Room"];
cloud_gateway["Cloud Gateway"] ---|"Cloud Gateway: Port 9 (Core Switch) <-> Core Switch: Port 1 (Cloud Gateway)"| core_switch["Core Switch"];
class cloud_gateway node_gateway;
class core_switch node_switch;
class ap_living_room node_ap;
class ap_attic node_ap;
classDef node_gateway fill:#ffe3b3,stroke:#d98300,stroke-width:1px;
classDef node_switch fill:#d6ecff,stroke:#3a7bd5,stroke-width:1px;
classDef node_ap fill:#d7f5e7,stroke:#27ae60,stroke-width:1px;
classDef node_client fill:#f2e5ff,stroke:#7f3fbf,stroke-width:1px;
classDef node_other fill:#eeeeee,stroke:#8f8f8f,stroke-width:1px;
classDef node_legend font-size:10px;
linkStyle 0 stroke:#1e88e5,stroke-width:2px,arrowhead:none;
linkStyle 1 stroke:#1e88e5,stroke-width:2px,arrowhead:none;
MkDocs Material example
See examples/mkdocs/ for a ready-to-use setup that renders Mermaid diagrams
with Material for MkDocs, including a sample unifi-network page and legend.
Options
The CLI groups options by category (Source, Functional, Mermaid, SVG, Output, Debug).
Source:
--site: overrideUNIFI_SITE.--env-file: load environment variables from a specific.envfile.--mock-data: use mock data JSON instead of the UniFi API.
Mock:
--generate-mock: write mock data JSON and exit.--mock-seed: seed for deterministic mock generation.--mock-switches: number of switches to generate (default 1).--mock-aps: number of access points to generate (default 2).--mock-wired-clients: number of wired clients to generate (default 2).--mock-wireless-clients: number of wireless clients to generate (default 2).
Functional:
--include-ports: show port labels (Mermaid shows both ends; SVG shows compact labels).--include-clients: add active clients as leaf nodes.--client-scope wired|wireless|all: which client types to include (default wired).--collapse-clients: group clients by uplink device into cluster nodes with count badges.--only-unifi: only include neighbors that are UniFi devices; when clients are included, filters to UniFi-managed clients.--no-cache: disable UniFi API cache reads and writes.--resolve-hostnames/--no-resolve-hostnames: resolve device IPs to hostnames via reverse DNS against the controller (default: on for mkdocs, off otherwise).
Mermaid:
--direction LR|TB: diagram direction (default TB).--group-by-type: group nodes by gateway/switch/AP in subgraphs.--legend-scale: scale legend font/link sizes (default 1.0).--legend-style auto|compact|diagram: legend rendering mode (auto uses compact for mkdocs).--legend-only: render just the legend as a separate Mermaid graph.
SVG:
--svg-width/--svg-height: override SVG output dimensions.--theme: built-in theme (unifi,unifi-dark,minimal,classic,classic-dark).--theme-file: custom theme YAML (takes priority over--theme; seeexamples/theme.yaml).--icon-set isometric|modern|unifi: icon set to use (default: determined by theme, orisometric).--svg-layout-mode physical|grouped|vlan: layout mode for SVG output (default physical).--iso-compact-layout: forsvg-iso, pack each hub and its clients into a compact district instead of spreading siblings along a single diagonal.--iso-route-around-nodes: forsvg-iso, route edges around intervening nodes instead of always turning on the same axis.--wan-label/--wan-speed: WAN1 ISP name and provisioned speed.--wan2-label/--wan2-speed: WAN2 ISP name and provisioned speed.--max-vlan-colors: limit VLAN colors shown on edges (default: no limit).--include-vlan-legend: add VLAN color legend to SVG output.
Output:
--format mermaid|svg|svg-iso|lldp-md|mkdocs|json: output format (default mermaid).--stdout: write output to stdout.--output: write output to file.--markdown: wrap Mermaid output in a code fence for notes tools like Obsidian.--mkdocs-sidebar-legend: write sidebar legend assets next to the output file.--mkdocs-dual-theme: render light/dark Mermaid blocks for Material theme switching.--mkdocs-timestamp-zone: timezone for mkdocs timestamp (defaultEurope/Amsterdam; useoffto disable).
Debug:
--debug-dump: dump gateway + sample devices to stderr for debugging.--debug-sample N: number of non-gateway devices in debug dump (default 2).
Themes
Five built-in themes are available via --theme:
| Theme | Style | Default icon set |
|---|---|---|
unifi |
Clean light theme based on the ui.com color palette | modern |
unifi-dark |
Dark variant using official Ubiquiti dark surface colors | modern |
minimal |
Neutral grey tones, understated | isometric |
classic |
Warm default palette with distinct device colors | isometric |
classic-dark |
Dark variant of classic | modern |
For custom colors, create a theme YAML and pass it with --theme-file. Override only the values you need:
mermaid:
nodes:
gateway:
fill: "#ffe3b3"
stroke: "#d98300"
poe_link: "#1e88e5"
svg:
icon_set: modern
grid_color: "#c0c8d0"
background: "#f9fafa"
links:
standard:
from: "#006fff"
to: "#0560d4"
nodes:
switch:
from: "#4dd88a"
to: "#38cc65"
See examples/theme.yaml and examples/theme-dark.yaml for full examples.
Notes
- Default output is top-to-bottom (TB) and rendered as a hop-based tree from the gateway(s).
- Nodes are color-coded by type (gateway/switch/AP/client) with a sensible default palette.
- PoE links are annotated with a power icon when detected from
port_table. - Wireless client links render as dashed lines to indicate the last-known upstream.
- SVG port labels render inside child nodes for readability.
- Icon licenses and attribution are documented in LICENSES.md.
AI Disclosure
This project used Claude as a coding assistant for portions of the implementation and documentation.
Metadata
Release files for unifi-network-maps 2.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| unifi_network_maps-2.3.2.tar.gz | 60.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unifi_network_maps-2.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 91.3 kB
Release files / unifi_network_maps-2.3.2.tar.gz
| Download URL | unifi_network_maps-2.3.2.tar.gz |
|---|---|
| Size | 60.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3db5b22f665d83bbf478d3a6803220746e1b2833c709242cad4238e7ced4ea37
|
|
BLAKE2b-256 checksum How to use checksums |
1f638f51762eaed6b5291d513099ceeefa8dd4acfe515bf3ea4cbaaa2b9d6d5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 27, 2026.
Transparency logRelease files / unifi_network_maps-2.3.2-py3-none-any.whl
| Download URL | unifi_network_maps-2.3.2-py3-none-any.whl |
|---|---|
| Size | 30.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b69dfd412fd4c297f0d72eb3d36f9006922b1f7812af740241096c1c9156dcf5
|
|
BLAKE2b-256 checksum How to use checksums |
c983f71799d7575c584e27396a644e5bdb28a9ea48ca5d939cf24152d9f105d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 27, 2026.
Transparency logSecurity for unifi-network-maps 2.3.2
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for unifi_network_maps-2.3.2.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 Jul 27, 2026.
Transparency logA 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.