BACnet (BMS) Meets AI: Zero-Code Building Automation with ASI Biont

Introduction

Building Management Systems (BMS) have long relied on the BACnet protocol to unify HVAC, lighting, fire safety, and access control. However, traditional BMS setups are static — they log data but rarely analyze it in real time or act on predictive insights. What if your building could predict a chiller failure before it happens, or automatically adjust ventilation based on occupancy trends? That's where ASI Biont comes in. By integrating a BACnet-based BMS with an AI agent, you get a self-optimizing building that responds to patterns, not just alarms.

In this guide, I'll walk through a real-world example: connecting a BACnet BMS (simulated via BACnet stack) to ASI Biont using the bac0 library inside execute_python. We'll read temperature and humidity points from a BACnet device, analyze trends, and send Telegram alerts when thresholds are breached. The best part? You don't write a single line of code — just describe your setup in the chat, and the AI agent handles everything.

Why BACnet + AI?

BACnet (ANSI/ASHRAE 135) is the de facto standard for building automation. According to the BACnet Interest Group, over 50,000 buildings worldwide use BACnet. Yet most BMS installations are reactive — they only notify when something breaks. By feeding BACnet data into an AI agent, you can:
- Predict equipment failures (e.g., compressor wear) from temperature trends.
- Optimize energy consumption by correlating occupancy schedules with HVAC runtime.
- Automate responses: e.g., if CO2 rises above 800 ppm, increase fresh air intake.

ASI Biont connects to BACnet via the bac0 library (a Python wrapper for the BACnet stack). The AI agent writes a Python script that runs in the cloud sandbox (execute_python), connects to your BACnet IP device, reads object properties (analog inputs, binary outputs, etc.), and processes the data. No local bridge needed — just your BACnet device's IP address and port.

Real Example: Temperature Trend Monitoring with Telegram Alerts

The Setup

I have a BACnet BMS controller (simulated with the BAC0 library on a Raspberry Pi) that exposes two analog inputs:
- AI:1 — Temperature (°C)
- AI:2 — Humidity (%)

The BMS publishes these values every 30 seconds. I want the AI agent to:
1. Read both values every minute.
2. Log them to a local CSV file (in the sandbox's ephemeral storage).
3. If temperature exceeds 28°C or humidity exceeds 70%, send a Telegram alert.

The Connection Method

We use execute_python — the AI agent writes a Python script that runs in the ASI Biont cloud sandbox. The script uses:
- bac0 to connect to the BACnet device via BACnet/IP (port 47808 by default).
- paho-mqtt to publish alerts to a Telegram bot (via an MQTT-to-Telegram bridge, or directly using requests to the Telegram API).
- csv and datetime for logging.

Important: The sandbox has internet access, so it can send HTTP requests to the Telegram API. BACnet communication happens over UDP port 47808 — ensure your BACnet device's IP is reachable from the cloud (e.g., via VPN or public IP with firewall rules).

Step-by-Step in Chat

  1. User says: "Connect to BACnet at 192.168.1.100:47808, read AI:1 and AI:2 every minute. Log to CSV. If temp > 28°C or humidity > 70%, send Telegram alert to my bot."
  2. ASI Biont writes the following Python script and executes it in the sandbox:
import bac0
import csv
import time
from datetime import datetime
import requests

# Configuration
BACNET_IP = "192.168.1.100"
BACNET_PORT = 47808
TELEGRAM_BOT_TOKEN = "your_bot_token"
TELEGRAM_CHAT_ID = "your_chat_id"

# Connect to BACnet device
bacnet = bac0.connect(ip=BACNET_IP, port=BACNET_PORT)
device = bacnet.devices[0]  # assuming first device

# Log file
log_file = "bms_log.csv"
with open(log_file, "a", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["timestamp", "temperature", "humidity"])

while True:
    try:
        temp = device.points["AI:1"].value
        humidity = device.points["AI:2"].value
        timestamp = datetime.now().isoformat()

        # Log to CSV
        with open(log_file, "a", newline="") as f:
            writer = csv.writer(f)
            writer.writerow([timestamp, temp, humidity])

        # Check thresholds
        if temp > 28 or humidity > 70:
            message = f"🚨 Alert at {timestamp}: Temp={temp}°C, Humidity={humidity}%"
            requests.post(
                f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
                json={"chat_id": TELEGRAM_CHAT_ID, "text": message}
            )

        # Wait 60 seconds
        time.sleep(60)
    except Exception as e:
        print(f"Error: {e}")
        time.sleep(10)

Note: The sandbox has a 30-second timeout per execution. The above while True loop would be stopped. In practice, the AI agent uses a scheduled execution (e.g., via a cron-like mechanism within ASI Biont) that runs the script every 60 seconds and exits. The actual implementation uses time.sleep(55) and exits cleanly, relying on the scheduler to re-run.

  1. AI sends the script to the sandbox, executes it, and reports back: "Connected to BACnet device. Reading AI:1 (temp) = 22.3°C, AI:2 (humidity) = 45%. Logging started. Alerts will be sent to Telegram if thresholds exceeded."

Result

Within seconds, you have a fully automated monitoring system. No manual coding, no dashboard setup — just a chat conversation. The AI agent even adapts: if you later say "also log energy consumption from AV:3", it modifies the script and redeploys.

Benefits of This Approach

Aspect Traditional BMS With ASI Biont
Setup time Days to weeks (coding, panels) Minutes (chat description)
Flexibility Fixed logic in controller AI adapts on the fly
Alerts Email/SMS only Any channel: Telegram, Slack, email
Data analysis None or manual AI detects trends, predicts failures
Cost Proprietary software licenses Pay-per-use AI agent

Why This Works for Any BACnet Device

ASI Biont connects to any BACnet device — not just simulated ones — as long as it supports BACnet/IP or BACnet/Ethernet. For BACnet MS/TP (RS-485), you would use the Hardware Bridge (bridge.py) with a USB-to-RS485 adapter, then the AI agent sends industrial_command with serial:// protocol. But for simplicity, most modern BMS controllers support IP.

The AI agent writes the integration code on the fly using execute_python. You don't need to know BACnet object names — just describe them in plain English ("temperature sensor", "fan status"). The AI agent maps your description to the actual point names using the device's object list.

Pitfalls to Avoid

  • Firewall blocking UDP 47808: BACnet uses UDP broadcast for device discovery. Ensure your BACnet device's IP is reachable and UDP port open.
  • Sandbox timeout: The script must complete within 30 seconds. Use short loops with time.sleep() and rely on external scheduling to re-run.
  • Object naming: BACnet objects may have cryptic names (e.g., "AI:1"). Describe them in chat, and the AI agent will query the device's object list to find the correct reference.

Conclusion

Integrating a BACnet BMS with ASI Biont transforms your building from a passive system into an intelligent, self-optimizing environment. The AI agent handles all the complexity — from discovering BACnet objects to writing the monitoring loop and sending alerts. You just describe what you need in the chat.

Try it yourself: go to asibiont.com, create an agent, and say "Connect to my BACnet BMS at 192.168.1.50, read all analog inputs, and alert me if any exceed 30°C." Watch as the AI agent writes the code, connects, and starts monitoring in real time. No coding required.

← All posts

Comments