CLI toolkit for Home Assistant Zigbee — migrate ZHA → Z2M, cascade-rename entities and devices, and map your mesh.
Project description
zigporter
Manage your Home Assistant Zigbee network from the terminal.
Migrate ZHA → Z2M, cascade-rename entities and devices, and map your mesh.
Features
Interactive Demo → — see every command in action before installing.
Network map example → — radial SVG diagram of your Zigbee mesh with LQI-coloured edges and per-device signal badges.
| Command | Description |
|---|---|
migrate | Interactive wizard: remove from ZHA → factory reset → pair with Z2M → restore names, areas, and entity IDs |
rename‑entity | Rename a HA entity ID and cascade the change across automations, scripts, scenes, and all Lovelace dashboards |
rename‑device | Rename any HA device by name and cascade the change to all its entities and references |
check | Verify HA and Z2M connectivity before making changes |
inspect | Show a device's current state across ZHA, Z2M, and the HA registry |
export | Snapshot your ZHA device inventory to JSON |
list‑z2m | List all devices currently paired with Zigbee2MQTT |
fix‑device | Post-migration cleanup: remove stale ZHA device entries, delete their entities, and rename any _2/_3 suffixed Z2M entities back to their original IDs |
stale | Scan all integrations for offline devices and interactively remove, annotate, ignore, or permanently suppress them |
network‑map | Generate a radial SVG diagram of your Zigbee mesh with LQI-coloured edges, hop rings, and per-device signal badges — or print a routing tree and signal table to the terminal |
Installation
uv tool install zigporter
Or with pip:
pip install zigporter
Configuration
Run the setup wizard to get started:
zigporter setup
This prompts for HA credentials (required) and Zigbee2MQTT settings (optional — only needed for migrate and list-z2m).
You can also set environment variables directly or create the file manually:
| Variable | Required | Description |
|---|---|---|
HA_URL |
Yes | Home Assistant base URL |
HA_TOKEN |
Yes | Long-Lived Access Token |
HA_VERIFY_SSL |
No | true (default) or false for self-signed certificates |
Z2M_URL |
Only for migrate and list-z2m |
Zigbee2MQTT ingress URL |
Z2M_MQTT_TOPIC |
Only for migrate and list-z2m |
Z2M base MQTT topic (default: zigbee2mqtt) |
See Configuration for full details.
Migrate ZHA → Zigbee2MQTT
[!WARNING] Back up first — The migration wizard removes devices from ZHA and makes changes to entity IDs, automations, and dashboards that are difficult to reverse. Before running, back up your Home Assistant configuration. This tool is provided as-is with no warranty. Use at your own risk.
# Verify connectivity first
zigporter check
# Run the migration wizard
zigporter migrate
The wizard guides you through each device one at a time:
- Remove from ZHA — polls the HA registry until the device is gone
- Factory reset — prompts to clear the old pairing on the physical device
- Pair with Z2M — opens a 300 s permit-join window and polls by IEEE address
- Rename — restores the original ZHA name and area in Z2M and HA
- Restore entity IDs — renames IEEE-hex entity IDs back to friendly names; detects
_2/_3suffix conflicts caused by stale ZHA entries and offers to delete them and rename the Z2M entities back to their original IDs - Review — shows all Lovelace cards referencing the device
- Validate — polls HA entity states until all entities come online; offers a "Reload Z2M integration" option to force-refresh sensor state without leaving the CLI
Progress is saved after every step. Press Ctrl-C to pause; rerun to resume.
# Check progress without entering the wizard
zigporter migrate --status
Fix a Previously Migrated Device
If you migrated a device before the suffix-conflict fix was added, or if stale ZHA entries
were left behind, use fix-device to clean them up:
zigporter fix-device
The command scans HA for devices that have both a stale ZHA entry and an active Z2M entry,
lets you pick one, deletes the stale ZHA entities, removes the ZHA device from the registry,
and renames any _2/_3 suffixed Z2M entities back to their original IDs so dashboard
cards work again.
Find and Clean Up Offline Devices
Scan HA for devices whose entities are all unavailable or unknown:
zigporter stale
The command lists every offline device grouped as New / Stale / Ignored. For each device you can:
- Remove — delete the entry from the HA registry
- Mark as stale — add a note and come back later
- Ignore — mark devices you know are intentionally offline
- Suppress — permanently hide a ghost entry or false positive from all future runs
- Clear status — reset to New (also un-suppresses a suppressed device)
Resolved entries (devices that came back online since your last run) are pruned from the state file automatically. Hub and gateway devices with active children (e.g. a Plejd GWY-01 whose lights are responsive) are automatically excluded to avoid false positives.
Rename an Entity
Rename a Home Assistant entity ID and automatically update every reference — automations, scripts, scenes, and Lovelace dashboards.
Both arguments are optional. Run with no arguments for a guided wizard:
# Interactive wizard — pick entity from a list, edit the new ID in-place
zigporter rename-entity
# Provide the old ID only — prompts for the new ID (pre-filled for editing)
zigporter rename-entity sensor.old_device_energy
# Preview changes (dry run)
zigporter rename-entity light.living_room_1 light.living_room_ceiling
# Apply the rename
zigporter rename-entity light.living_room_1 light.living_room_ceiling --apply
Without --apply the command shows a full diff and prompts for confirmation before writing.
New entity IDs are validated against the domain.entity_name format before any changes are made.
Note: Jinja2 template expressions (
{{ states('old.id') }}) are not patched automatically — review them after renaming.
Rename a Device
Rename any Home Assistant device by name and cascade the change to all its entities and references in HA. Supports partial name matching.
Both arguments are optional. Run with no arguments for a guided wizard:
# Interactive wizard — pick device from an area-grouped list, type the new name
zigporter rename-device
# Restrict the picker to Zigbee devices only (ZHA + Zigbee2MQTT)
zigporter rename-device --filter=zigbee
# Provide the old name only — prompts for the new name
zigporter rename-device "Living Room 1"
# Preview changes (dry run)
zigporter rename-device "Living Room 1" "Living Room Ceiling"
# Apply the rename
zigporter rename-device "Living Room 1" "Living Room Ceiling" --apply
If Z2M_URL is configured and the device is managed by Zigbee2MQTT, the command also
offers to rename the Z2M friendly name in a separate prompt — so you stay in control of
whether HA and Z2M names are kept in sync.
Visualise the Zigbee Mesh
Generate a radial SVG map of your network with LQI-coloured edges and per-device path-quality badges. Works with Zigbee2MQTT and ZHA — zigporter auto-detects which backend is available, or you can select one explicitly:
# Auto-detect backend (prompts if both Z2M and ZHA are available)
zigporter network-map --output network.svg
# Explicit backend selection
zigporter network-map --backend z2m --output z2m_network.svg
zigporter network-map --backend zha --output zha_network.svg
# Table view (sortable columns) instead of tree
zigporter network-map --format table
# Adjust LQI thresholds (edges and glows change colour accordingly)
zigporter network-map --output network.svg --warn-lqi 100 --critical-lqi 50
Open the .svg in any browser — hover over truncated device names to see the full name.
Confirmed Working
Platform
| OS | Linux, macOS, Windows 11 |
Software
| Version | |
|---|---|
| Home Assistant OS | 2026.2.3 |
| HA Supervisor | 2026.02.2 |
| HA install type | HA OS |
| Zigbee2MQTT | 2.8.0-1 |
| Python | 3.12, 3.13, 3.14 |
Running a different version? Submit a compatibility report to let us know.
Development
See CONTRIBUTING.md for setup instructions, code style, and how to submit a pull request.
uv sync --dev
uv run pytest
uv run ruff check .
uv run ruff format .
See Development for architecture details and contribution guidelines.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
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 zigporter-1.0.1.tar.gz.
File metadata
- Download URL: zigporter-1.0.1.tar.gz
- Upload date:
- Size: 73.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
424be7fa8485c37c94564da66ec78743d9211eae0a1ad76c982cb8c21758b6fd
|
|
| MD5 |
8dcfd7ae2fc9f7a01ffeef838f28952a
|
|
| BLAKE2b-256 |
2e7933224e3ee22b63df125859a2d78f35578ee2657bcc32f41534a263f4fd20
|
File details
Details for the file zigporter-1.0.1-py3-none-any.whl.
File metadata
- Download URL: zigporter-1.0.1-py3-none-any.whl
- Upload date:
- Size: 88.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3702e6d1b04cd31f2d67a17729b081b5f2f144535b44d42e954700826df0c0d8
|
|
| MD5 |
2ceeef2d82f551c759dd22df8be4c28e
|
|
| BLAKE2b-256 |
7779085044e39ac264307b379e0b7d703816c58ed184ddb7fbf978f9e4b5bbfb
|