zigpy-zigate
zigpy-zigate is a Python 3 library that provides an implementation for the `zigpy` project, enabling communication with ZiGate based Zigbee radio devices. It acts as a hardware abstraction layer for ZiGate USB, USB-DIN, PiZiGate, and ZiGate Ethernet modules. The library is actively maintained and is primarily used as a backend for Zigbee Home Automation (ZHA) integrations in Home Assistant. Its current version is 0.13.4, with releases generally following the development pace of `zigpy` and Home Assistant's ZHA component.
Common errors
-
AttributeError: module 'zigpy.types' has no attribute 'HexRepr'
cause This error typically occurs when using development or unreleased branches of `zigpy-zigate` with an incompatible (often older) development branch of `zigpy`, where `HexRepr` was moved or renamed.fixEnsure that both `zigpy` and `zigpy-zigate` are installed from stable releases or that their development branches are mutually compatible. Pin versions if necessary (e.g., `pip install zigpy==X.Y.Z zigpy-zigate==A.B.C`). -
ERROR: Command errored out with exit status 1: ... Unable to install package zigpy-zigate==X.X.X
cause Installation failures, particularly around versions 0.7.x, were sometimes linked to conflicts with the `typing` package and specific `pip` versions, especially in older Python environments (e.g., Python 3.8 with older pip).fixTry upgrading `pip` (`python3 -m pip install --upgrade pip`). If the issue persists, a specific workaround involved uninstalling `typing` and downgrading `pip` to version 20.0.2 or lower, then reinstalling `zigpy-zigate`. However, generally, ensure your Python environment is up-to-date. -
Home Assistant ZHA component not starting with zigpy-zigate after upgrade (e.g., to 2022.10.0)
cause Upgrades to Home Assistant or underlying `zigpy` components can introduce incompatibilities if `zigpy-zigate` is not also updated or if there are specific system configuration requirements (like UART enablement on Raspberry Pi).fix1. Ensure `zigpy-zigate` is updated to the latest compatible version (`pip install --upgrade zigpy-zigate`). 2. Verify system-level configurations for serial communication (e.g., `enable_uart=1` in `/boot/config.txt` and removing `console=serial0,115200` from `/boot/cmdline.txt` on Raspberry Pi for PiZiGate).
Warnings
- breaking Future deprecation within Home Assistant's ZHA integration: An issue was opened in April 2025 to discuss deprecating XBee and ZiGate radio support within the `zigpy/zha` project, which is the primary consumer of `zigpy-zigate`. This indicates a potential future breaking change for users relying on `zigpy-zigate` through Home Assistant ZHA.
- gotcha ZiGate Firmware Compatibility: ZiGate hardware requires firmware 3.1a or later to function with `zigpy-zigate`. Firmware 3.1d or later is strongly recommended as it includes critical bug fixes related to `zigpy` compatibility. Using older firmware can lead to unexpected issues or instability.
- gotcha Limited Feature Support: Some advanced Zigbee features are not supported by ZiGate adapters when used with `zigpy-zigate` and `zigbee-herdsman` (which can also use ZiGate). These include changing the Zigbee channel without re-pairing all devices, adding install codes (required for some devices), full backups, and Inter-PAN communication (required for Touchlink).
Install
-
pip install zigpy-zigate
Imports
- Controller
from zigpy_zigate import ZiGateController
from zigpy.application import Controller import zigpy_zigate
Quickstart
import asyncio
import os
from zigpy.application import Controller
from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH, CONF_RADIO_TYPE
# Ensure zigpy-zigate is imported so its radio type is registered
import zigpy_zigate # noqa: F401
async def main():
# Replace '/dev/ttyUSB0' with your ZiGate's serial port
# For PiZiGate, it might be '/dev/serial0' or '/dev/ttyAMA0'
# For ZiGate Ethernet, it would be 'socket://IP_ADDRESS:PORT'
zigate_port = os.environ.get('ZIGATE_PORT', '/dev/ttyUSB0')
config = {
CONF_DEVICE: {
CONF_DEVICE_PATH: zigate_port,
CONF_RADIO_TYPE: 'zigate'
}
}
controller = None
try:
print(f"Initializing zigpy Controller with ZiGate on {zigate_port}...")
controller = await Controller.new(config)
print("Zigbee network initialized. Controller is running.")
# In a real application, you would now interact with the controller
# e.g., controller.add_endpoint(), controller.start_network(), etc.
print("Controller object created. You can now use it to manage your Zigbee network.")
print("Press Ctrl+C to stop.")
await asyncio.Event().wait() # Keep the event loop running indefinitely
except Exception as e:
print(f"Error during zigpy initialization: {e}")
finally:
if controller:
await controller.shutdown()
print("Controller shut down.")
if __name__ == "__main__":
asyncio.run(main())