Zigbee Deconz Radio Backend for Zigpy

0.25.5 · active · verified Thu Apr 16

zigpy-deconz is a Python library that provides a radio backend for the zigpy framework, enabling communication with Zigbee networks via a Deconz gateway (e.g., ConBee, RaspBee devices managed by the Deconz software). It acts as a bridge, allowing zigpy applications to leverage an existing Deconz installation for Zigbee operations. The current version is 0.25.5, and it typically releases updates in sync with new zigpy versions or significant Deconz API changes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the `Deconz` radio backend. For a complete Zigbee application, the instantiated `radio` object would then be passed to `zigpy.application.Controller` to manage the Zigbee network. Ensure your Deconz gateway is running and you have an API key from the Phoscon App.

import asyncio
import os
from zigpy.radio.deconz import Deconz

async def main():
    # Retrieve Deconz gateway details from environment variables
    # For a real setup, ensure the Deconz gateway is running and accessible
    deconz_host = os.environ.get('DECONZ_HOST', '127.0.0.1')
    deconz_port = int(os.environ.get('DECONZ_PORT', '80'))
    deconz_api_key = os.environ.get('DECONZ_API_KEY', 'YOUR_DECONZ_API_KEY_HERE') # Get API key from Deconz Phoscon App -> Gateway -> Advanced -> Authenticate app

    if deconz_api_key == 'YOUR_DECONZ_API_KEY_HERE':
        print("WARNING: Please set DECONZ_API_KEY environment variable or replace 'YOUR_DECONZ_API_KEY_HERE' with your actual Deconz API key.")
        print("You can obtain the API key from the Phoscon App (web interface for Deconz) by navigating to Gateway -> Advanced -> Authenticate app.")
        return

    # Deconz radio device configuration specific for zigpy
    device_config = {
        'path': f'socket://{deconz_host}:{deconz_port}',
        'api_key': deconz_api_key,
        # baudrate and flow_control are often ignored by Deconz but required by zigpy's device config structure
        'baudrate': 115200,
        'flow_control': 'software',
    }

    try:
        # Instantiate the Deconz radio object
        radio = Deconz(device_config)
        print(f"Deconz radio object created for {device_config['path']}.")
        # In a full zigpy application, you would pass this 'radio' object to zigpy.application.Controller
        # For this quickstart, we just demonstrate instantiation. A real connection attempt happens during controller.startup()
        print("Successfully instantiated zigpy.radio.deconz.Deconz. This object is now ready to be passed to a zigpy application controller.")

    except Exception as e:
        print(f"Failed to instantiate Deconz radio: {e}")
        print("Ensure Deconz gateway is running, accessible at the specified host/port, and the API key is correct.")

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →