z2m

Scoped Zigbee2MQTT and Home Assistant CLI for safe routine smart home operations.

Smart homeDaily useCode: not public yet

What it does

Managing smart home devices via raw MQTT messages is error-prone, especially when delegating maintenance tasks to AI coding agents. z2m provides a strictly scoped command-line interface for common Zigbee2MQTT and Home Assistant operations such as pairing, querying device states, renaming entities, and inspecting network topology. By wrapping complex MQTT payloads and API calls into simple deterministic commands, it allows autonomous agents and system operators to inspect devices and execute routine setup without manually crafting MQTT requests or risking unintended network-wide configuration changes.

  • Lists all paired Zigbee devices with their friendly name, IEEE address, device type, and model.
  • Reads the latest published state of any paired device.
  • Manages pairing windows safely, including single-device pairing that automatically closes once a device joins.
  • Manually opens or closes the pairing window.
  • Synchronizes device renaming across both Zigbee2MQTT and Home Assistant entity IDs.
  • Summarizes the mesh network topology, showing connections between routers and link quality indicators.

Commands

CommandWhat it does
z2m estadoLists paired devices with their name, IEEE address, type, and model.
z2m leer "Living Room Light"Prints the latest state payload published by the device.
z2m emparejar 120Opens pairing for up to 120 seconds, waits for one device to join, then closes pairing.
z2m abrirManually opens the Zigbee pairing window for 254 seconds.
z2m cerrarImmediately closes the Zigbee pairing window.
z2m renombrar "Old Name" "New Name"Renames a device in Zigbee2MQTT and updates corresponding Home Assistant entity IDs.
z2m mapaDisplays a summary of the network topology and link quality (LQI).

Design principles

  • Narrow scope: exposes only essential routine tasks to prevent accidental configuration errors.
  • Agent-friendly interface: removes the need for manual MQTT payload assembly.
  • Clean naming enforcement: avoids accents in device names to ensure clean Home Assistant entity IDs.

Built with

PythonDocker

Works with

Zigbee2MQTTHome Assistant