Zigbee (ZHA, Zigbee2MQTT) Meets ASI Biont: Automate Your Smart Home by Chatting with an AI Agent

Your home is full of Zigbee devices — sensors, switches, plugs — all silently chattering on a 2.4 GHz mesh network. You likely have a coordinator like a Conbee II or a Sonoff Zigbee dongle, and you run a bridge stack like Zigbee2MQTT or Home Assistant's ZHA integration. But the moment you try to automate something more complex than a single rule, you hit a wall: YAML configs, MQTT topic debugging, or a Node-RED flow that breaks the moment a device re-pairs. What if you could just describe the automation in plain English and have an AI agent write and execute the integration for you? That is exactly the gap ASI Biont fills. It connects to your Zigbee network over MQTT (or any other protocol), writes the necessary Python code in seconds, and lets you control devices from a chat dialog — no dedicated management panel required.

ASI Biont is an AI agent designed for industrial and IoT environments. It speaks the language of machines: MQTT, Modbus, BACnet, OPC-UA, RS-485 via a hardware bridge, and more. For Zigbee, the most practical path is MQTT because Zigbee2MQTT already translates every Zigbee message into a clean JSON packet that travels over an MQTT broker. ZHA can also be bridged via the Home Assistant MQTT integration, but the majority of DIY smart homes use Zigbee2MQTT due to its independence from Home Assistant. By connecting ASI Biont to the same broker, you give the AI agent a live view of your entire Zigbee mesh — and a way to act on it.

Why Zigbee needs an AI agent

Zigbee is a beautiful radio mesh, but the logic that runs on top of it is often painfully static. You set a few automations in Zigbee2MQTT or Home Assistant, and any new behavior requires editing rules or writing a small script. An AI agent changes the equation. Instead of translating 'I want the lamp on when the door opens, but not during the day' into a complex state machine, you can write that sentence in a chat and ASI Biont generates the correct MQTT subscription and publish commands. It can also reason about device states, time, and events together, creating automations that would take dozens of lines of code to implement manually.

From a technical standpoint, Zigbee devices expose a set of clusters (on/off, occupancy, temperature, etc.). Zigbee2MQTT maps these to simple topics like zigbee2mqtt/0x00158d0002abcd for state and .../set for commands. This is a highly developer-friendly interface. Yet the knowledge of exactly which topic and payload to use is often buried in documentation. ASI Biont is trained on these protocol details, and if it is unsure, it asks you or inspects the device by subscribing to its state topic for a few seconds. That is a level of adaptability that a static YAML rule cannot match.

Zigbee control plane: ZHA vs Zigbee2MQTT

Before we dive into the integration, let's clarify what you are likely running.

Characteristic Zigbee2MQTT ZHA (Home Assistant)
Standalone Yes, independent No, part of Home Assistant
MQTT native First-class citizen Requires bridge to MQTT
Supported adapters Many USB/TCP coordinators Many, but tied to HA version
Device support Actively updated via external converters Large but occasionally slower
Best for Pure MQTT setups and ASI Biont Users already living in HA ecosystem

Both stacks talk to a Zigbee coordinator over a serial protocol (usually via USB). With Zigbee2MQTT, every state change is published to zigbee2mqtt/<friendly_name> as a JSON object, and commands go to zigbee2mqtt/<friendly_name>/set, according to the official Zigbee2MQTT documentation. This protocol is extremely easy to consume from Python. If you are on ZHA, you can still expose devices via MQTT using the Home Assistant MQTT integration, but Zigbee2MQTT is the cleaner option for an MQTT-centric agent like ASI Biont.

Connecting ASI Biont to Zigbee2MQTT over MQTT

There is no physical wire to run. The integration is network-only. You need three things:

  1. A running Zigbee2MQTT instance with an MQTT broker (for example, Mosquitto).
  2. Network access from the ASI Biont host to that broker.
  3. A chat dialog with ASI Biont where you describe the connection parameters.

Here is what that dialog might look like. You type:

Connect to my Zigbee2MQTT broker at 192.168.1.100:1883, username mqtt_user, password mqtt_pass. Then subscribe to all zigbee2mqtt/+/ state topics and report devices that are currently on.

ASI Biont then writes a Python script using paho-mqtt and runs it in its sandbox. The hardest part of MQTT integration — writing the callback, parsing JSON, and managing a session — is handled instantly. Here is the kind of code it generates for publishing a command to a Zigbee plug:

import paho.mqtt.client as mqtt
import json

client = mqtt.Client()
client.username_pw_set('mqtt_user', 'mqtt_pass')
client.connect('192.168.1.100', 1883, 60)

plug_topic = 'zigbee2mqtt/0x00158d0002abcd/set'
client.publish(plug_topic, json.dumps({'state': 'ON'}))
client.disconnect()
print('Command sent to Zigbee plug.')

If you ask it to monitor a motion sensor, it will use an MQTT callback:

import paho.mqtt.client as mqtt
import json
import time

def on_message(client, userdata, msg):
    payload = json.loads(msg.payload)
    if 'occupancy' in payload:
        print('occupancy:', payload['occupancy'])

client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.100', 1883, 60)
client.subscribe('zigbee2mqtt/0x00158d0002abcd')
client.loop_start()
time.sleep(5)
client.loop_stop()

Note the deliberately short run time: ASI Biont's sandbox executes Python scripts for a limited period (typically 30 seconds), so long-running daemons are not the right pattern here. Instead, ASI Biont uses the script to validate the connection and extract immediate state. For continuous automations, it can deploy the same logic as a persistent service on a local machine via SSH, or you can run the generated script yourself. This separation of concerns keeps the sandbox safe while still providing full connectivity.

Discovering devices with MQTT wildcards

To understand what is on your Zigbee network, ASI Biont doesn't need a web dashboard. It simply subscribes to the wildcard topic zigbee2mqtt/# and listens for a few seconds. Because most Zigbee state updates are published with the retained flag, you immediately get a snapshot of every device that has reported recently. This is a technique I use all the time when a user forgets the exact friendly name of a plug or sensor.

import paho.mqtt.client as mqtt
import time

def on_message(client, userdata, msg):
    print(msg.topic, msg.payload)

client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.100', 1883, 60)
client.subscribe('zigbee2mqtt/#')
client.loop_start()
time.sleep(4)
client.loop_stop()

The output is a list of topics like zigbee2mqtt/0x00158d0002abcd and their JSON payloads. ASI Biont then asks you which device you want to control, or you can simply refer to it by its human-friendly name if you have configured one in Zigbee2MQTT. This discovery step is a perfect example of how an AI agent eliminates manual research.

Troubleshooting from the chat

Suppose a Zigbee switch stops responding. Instead of opening logs, you tell ASI Biont: Check the Zigbee2MQTT log for errors. The AI knows that zigbee2mqtt/bridge/log carries key events published by the bridge. It subscribes to that topic for a few seconds, filters for error and warning messages, and returns a summary:

import paho.mqtt.client as mqtt
import time

def on_log(client, userdata, msg):
    payload = msg.payload.decode()
    if 'error' in payload.lower() or 'warn' in payload.lower():
        print(payload)

client = mqtt.Client()
client.on_message = on_log
client.connect('192.168.1.100', 1883, 60)
client.subscribe('zigbee2mqtt/bridge/log')
client.loop_start()
time.sleep(3)
client.loop_stop()

This is a useful example because it shows how ASI Biont can not only act but also diagnose. The conversation becomes a two-way loop: you ask, it listens, it explains, and together you solve the problem. No need to SSH into the Zigbee2MQTT host and inspect log files.

Real use case: motion-based morning coffee

Let's walk through one realistic scenario. You have a Zigbee motion sensor in the bedroom and a Zigbee smart plug that powers your coffee maker. You want the coffee maker to switch on only when motion is detected between 6:00 and 8:00 in the morning. In a traditional system, you would create a time-based automation and link it to the motion sensor. With ASI Biont, you just say:

Automate my coffee maker: when motion is detected in the bedroom between 6am and 8am, turn on the plug for 10 minutes.

ASI Biont will ask for the device IDs if it doesn't know them. It can even discover them instantly by subscribing to zigbee2mqtt/# as shown above. Then it generates a script that combines time conditions and MQTT messages. The core logic looks like this:

import paho.mqtt.client as mqtt
import json
import datetime
import time

PLUG_SET_TOPIC = 'zigbee2mqtt/0x00158d0002abcd/set'
SENSOR_TOPIC = 'zigbee2mqtt/0x00158d0002abcd'

def on_message(client, userdata, msg):
    payload = json.loads(msg.payload)
    if payload.get('occupancy') is True:
        now = datetime.datetime.now().time()
        if
← All posts

Comments