Introduction
If you’ve built a Z-Wave smart home—with sensors, switches, and locks from brands like Aeotec, Fibaro, or Zooz—you know the pain of managing multiple apps and rules. What if you could control everything through a single AI agent that understands natural language and writes its own integration code? That’s exactly what ASI Biont does. In this guide, I’ll show you how to connect your Z-Wave network to ASI Biont using MQTT and Home Assistant, and automate scenes like lighting, climate, and security—all without writing a single line of Python yourself. The AI handles the code; you just describe what you want.
Why Z-Wave and ASI Biont?
Z-Wave is a mature wireless protocol for home automation, known for its mesh reliability and low power consumption. But its ecosystem often relies on proprietary hubs or complex automation rules. ASI Biont, an AI agent with industrial connectivity, bridges that gap. By connecting your Z-Wave controller (via Home Assistant or Z-Wave JS UI) to ASI Biont through MQTT, you can:
- Control lights, thermostats, and locks with natural voice commands via Telegram or chat.
- Automate scenes based on sensor data (e.g., turn off lights when no motion detected).
- Get real-time alerts (e.g., door opened while you’re away).
- Analyze energy usage and optimize schedules.
Connection Method: MQTT via Home Assistant
ASI Biont supports MQTT natively through its execute_python sandbox, which has paho-mqtt installed. For Z-Wave, the most practical approach is:
- Set up Home Assistant (or Z-Wave JS UI) with a Z-Wave stick (e.g., Aeotec Z-Stick Gen5).
- Enable the MQTT integration in Home Assistant (using Mosquitto broker, either standalone or via add-on).
- Configure ASI Biont to subscribe to Home Assistant’s MQTT topics and publish commands.
Why MQTT? It’s lightweight, real-time, and works perfectly with both Home Assistant and ASI Biont’s sandbox. No need for complex bridges—just a broker and a few lines of Python generated by the AI.
Step-by-Step Integration
1. Prerequisites
- A Z-Wave controller (USB stick) and at least one Z-Wave device (e.g., a smart plug, motion sensor, or thermostat).
- Home Assistant running on a Raspberry Pi, Docker, or a VM. I used Home Assistant OS 2025.7.
- Mosquitto MQTT broker (install via Home Assistant add-on or standalone).
- ASI Biont account with an API key (get it from asibiont.com/dashboard → Devices → Create API Key).
bridge.pydownloaded from the dashboard (not from GitHub).
2. Setting Up Home Assistant for Z-Wave
- Plug in your Z-Wave stick and add the Z-Wave JS integration in Home Assistant.
- Include your Z-Wave device (e.g., a Fibaro motion sensor) using the Z-Wave JS UI.
- Verify the device appears in Home Assistant with entities like
binary_sensor.motion_sensororlight.living_room_lamp. - Enable MQTT integration in Home Assistant: go to Configuration → Integrations → Add MQTT. Set broker IP (e.g.,
192.168.1.100) and port1883(default). - For better control, configure Home Assistant to publish state changes to MQTT topics automatically. You can do this by adding an automation or using the
mqtt.discoveryoption.
3. Connecting ASI Biont to MQTT
Now, in the ASI Biont chat, describe your setup. For example:
“Connect to my MQTT broker at 192.168.1.100:1883, subscribe to all topics under
zwave/, and allow me to control the living room light (topiczwave/living_room_light/set).”
The AI will generate and execute a Python script using paho-mqtt in the sandbox. Here’s what the generated code looks like (you don’t need to write it):
import paho.mqtt.client as mqtt
import json
BROKER = "192.168.1.100"
PORT = 1883
TOPIC_PREFIX = "zwave/"
def on_connect(client, userdata, flags, rc):
print("Connected with result code " + str(rc))
client.subscribe(TOPIC_PREFIX + "#")
def on_message(client, userdata, msg):
print(f"Received: {msg.topic} -> {msg.payload.decode()}")
# AI can analyze the data and trigger actions
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(BROKER, PORT, 60)
client.loop_start()
The AI runs this script in the sandbox (30-second timeout, no infinite loops) to verify connectivity. For persistent control, it uses the industrial_command tool with publish command.
4. Real Use Case: Motion-Activated Lights
Scenario: You have a Z-Wave motion sensor (e.g., Aeotec MultiSensor 6) and a Z-Wave smart plug controlling a lamp. When motion is detected, the lamp turns on; when no motion for 5 minutes, it turns off.
In the chat, say:
“Subscribe to
zwave/motion_sensor/state, and when it publishesON, publishONtozwave/lamp/set. When it publishesOFF, publishOFFtozwave/lamp/setafter a 5-minute delay.”
The AI generates a script that:
- Subscribes to
zwave/motion_sensor/state. - On receiving
ON, immediately publishesONtozwave/lamp/set. - On receiving
OFF, waits 300 seconds (usingtime.sleepor a timer) before publishingOFF. Since sandbox has a 30-second limit, the AI usesindustrial_commandto schedule a delayed command via the MQTT broker itself (e.g., using Home Assistant’s built-in delay).
Here’s the Python code that runs in the sandbox to handle the trigger:
import paho.mqtt.client as mqtt
import time
BROKER = "192.168.1.100"
PORT = 1883
motion_topic = "zwave/motion_sensor/state"
lamp_set_topic = "zwave/lamp/set"
def on_message(client, userdata, msg):
payload = msg.payload.decode()
if payload == "ON":
client.publish(lamp_set_topic, "ON")
print("Motion detected, lamp ON")
elif payload == "OFF":
# Schedule delayed off via a separate script or Home Assistant automation
client.publish(lamp_set_topic, "OFF")
print("No motion, lamp OFF")
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER, PORT, 60)
client.subscribe(motion_topic)
client.loop_start()
time.sleep(10) # Keep alive for 10 seconds; actual persistence via bridge
To make it persistent, you can run a bridge.py instance on your local PC (with MQTT support) or use Home Assistant’s own automations triggered by MQTT. But the AI handles the logic.
5. Voice Control via Telegram
Want to say “Turn off all lights” in a Telegram chat? Connect ASI Biont to a Telegram bot (built-in feature). Then:
“When I send the message ‘turn off all lights’ in Telegram, publish
OFFto topicszwave/living_room_light/set,zwave/kitchen_light/set, andzwave/bedroom_light/set.”
The AI creates a script that listens for Telegram messages via webhook and publishes MQTT commands accordingly.
Advanced Scenario: Climate Control with Thresholds
Setup: A Z-Wave thermostat (e.g., Trane Z-Wave Thermostat) and a temperature sensor. Goal: maintain room temperature at 22°C.
- Subscribe to
zwave/temperature/state. - If temperature > 24°C, publish
COOLtozwave/thermostat/mode/set. - If temperature < 20°C, publish
HEAT. - Log all readings to a CSV file for analysis.
The AI writes a script that:
import paho.mqtt.client as mqtt
import json
BROKER = "192.168.1.100"
temp_topic = "zwave/temperature/state"
thermo_topic = "zwave/thermostat/mode/set"
def on_message(client, userdata, msg):
temp = float(msg.payload.decode())
if temp > 24:
client.publish(thermo_topic, "COOL")
elif temp < 20:
client.publish(thermo_topic, "HEAT")
client = mqtt.Client()
client.on_message = on_message
client.connect(BROKER, 1883, 60)
client.subscribe(temp_topic)
client.loop_forever()
Since loop_forever() would block, the AI uses industrial_command with a scheduled task to check temperature every 5 minutes.
Pitfalls to Avoid
- Don’t hardcode IPs in the sandbox script—use environment variables or let the AI ask you during chat.
- MQTT QoS matters: For critical devices (locks, alarms), use QoS 1 or 2. Default is 0, which may drop messages.
- Home Assistant MQTT discovery can cause duplicate messages if you subscribe to wildcards. Filter by specific topics.
- Z-Wave inclusion range: Keep the stick close to devices during inclusion; mesh networking works better after.
- Security: Never expose MQTT to the internet without TLS and authentication. Use a local broker or VPN.
How ASI Biont Automates the Integration
The beauty of ASI Biont is that you don’t write the code yourself. In the chat, you simply describe:
- “Connect to my MQTT broker at 192.168.1.100:1883.”
- “Monitor the temperature sensor on topic
zwave/temperature.” - “If temperature exceeds 30°C, send me a Telegram alert and turn on the AC via
zwave/ac/set.”
The AI generates and executes the Python code using paho-mqtt, requests (for Telegram), and time. It debugs any errors interactively. If you need a persistent listener, it guides you to run bridge.py on your local machine, which keeps the WebSocket connection alive.
Why This Beats Traditional Smart Home Hubs
- No app overload: One AI agent controls everything—Z-Wave, Wi-Fi, Bluetooth, even industrial PLCs.
- Natural language: “Dim the living room lights to 50%” works without complex scenes.
- Self-healing: The AI can restart services, check device status, and suggest fixes.
Conclusion
Integrating Z-Wave with ASI Biont via MQTT unlocks a new level of smart home automation. You don’t need to be a programmer—just describe what you want, and the AI writes the integration code in seconds. Whether it’s motion-activated lights, voice-controlled thermostats, or security alerts, ASI Biont handles the heavy lifting.
Ready to try it? Go to asibiont.com, create a free account, and start a chat with the AI agent. Tell it: “Connect to my Z-Wave network via MQTT.” The AI will guide you through the rest. Your smart home has never been smarter.
Comments