Skip to main content

CLI tool to migrate Zigbee devices from ZHA to Zigbee2MQTT in Home Assistant

Project description

CI codecov Documentation PyPI - Version PyPI - Downloads Python 3.12+ License: MIT

zigporter

Because migrating 30 Zigbee devices in Home Assistant by hand is a special kind of misery.

CLI tool that automates the ZHA → Zigbee2MQTT migration in Home Assistant — one device at a time, with checkpoints so you can stop and pick up where you left off.

Early Development Notice This tool is in early development and has only been tested with one specific setup:

  • Home Assistant OS 2026.2.3
  • Supervisor 2026.02.2
  • Zigbee2MQTT 2.8.0-1

I have not had the possibility to test with different HA or Z2M versions and setups. Feedback is very welcome — please open an issue or submit a PR if you test with a different configuration.

Early Development Notice This tool is in early development and has only been tested with one specific setup:

  • Home Assistant OS 2026.2.3
  • Supervisor 2026.02.2
  • Zigbee2MQTT 2.8.0-1

I have not had the possibility to test with different HA or Z2M versions and setups. Feedback is very welcome — please open an issue or submit a PR if you test with a different configuration.

Requirements

  • Python 3.12+
  • uv
  • Home Assistant with ZHA and Zigbee2MQTT add-on

Installation

uv tool install zigporter

Configuration

Option 1 — Setup wizard (recommended)

zigporter setup

Prompts for all values and saves to ~/.config/zigporter/.env.

Option 2 — Manual config file

Create ~/.config/zigporter/.env (see .env.example for the template):

mkdir -p ~/.config/zigporter
cp .env.example ~/.config/zigporter/.env
# edit the file with your values

Option 3 — Environment variables

Export directly in your shell or add to ~/.zshenv / ~/.bashrc:

export HA_URL=https://your-ha-instance.local
export HA_TOKEN=your_token
export Z2M_URL=https://your-ha-instance.local/abc123_zigbee2mqtt
Variable Required Description
HA_URL Yes Home Assistant URL
HA_TOKEN Yes Long-Lived Access Token
HA_VERIFY_SSL No true / false (default: true; use false for self-signed certs)
Z2M_URL Yes Zigbee2MQTT ingress URL
Z2M_MQTT_TOPIC No Z2M base topic (default: zigbee2mqtt)

Usage

# Verify your setup before migrating (recommended first step)
zigporter check

# Run the migration wizard (runs checks automatically on first run)
zigporter migrate

# Check migration progress without entering the wizard
zigporter migrate --status

# (Optional) manually export your ZHA device inventory
zigporter export

# (Optional) inspect what's already in Z2M
zigporter list-z2m

zigporter migrate handles everything automatically on first run:

  1. Runs pre-flight checks (HA reachable, ZHA active, Z2M running)
  2. Prompts you to back up Home Assistant and your ZHA network
  3. Fetches a ZHA export if one is not found, or offers to refresh an existing one
  4. Opens the interactive migration wizard

All files are stored in ~/.config/zigporter/ so the tool works from any directory. Use --skip-checks on subsequent runs to skip the pre-flight checks.

How it works

The wizard migrates one device at a time through five steps:

  1. Remove from ZHA — confirms deletion in the HA registry
  2. Reset device — prompts you to factory-reset the physical device
  3. Pair with Z2M — opens a 120 s permit-join window and polls by IEEE address
  4. Rename — applies the original ZHA name and area in Z2M and HA
  5. Validate — polls HA entity states until all are online

State is written to zha-migration-state.json after every step. Ctrl-C marks the device FAILED — rerun to retry.

See the wiki for detailed diagrams and architecture docs.

Development

uv sync --dev
uv run pytest
uv run ruff check .
uv run ruff format .

License

MIT — see LICENSE.

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

zigporter-0.1.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zigporter-0.1.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file zigporter-0.1.0.tar.gz.

File metadata

  • Download URL: zigporter-0.1.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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

Hashes for zigporter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e76d59708a4da60f4d5bd8e4c0b90659782f3453171ce73651518981896443c
MD5 5e829340655003852106de504993e119
BLAKE2b-256 69360b06df039f41b05b227adac1173b53e0b3a45858cb4cb987e15e5a289721

See more details on using hashes here.

File details

Details for the file zigporter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zigporter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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

Hashes for zigporter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e959cefb9773b186ec364b67fa95bba5a9c6989b616b116e2f789b2f8e5010be
MD5 939c9a80aedb9e64abcde77717a3f609
BLAKE2b-256 14e6363ec47f879a48ccff9cd22cbc0d969d72143704d7300d7050915711e396

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page