Introduction: The Smart Home That Thinks for Itself
Home Assistant is the Swiss Army knife of smart home platforms — it connects over 2,000 devices from 1,000+ brands, from Philips Hue lights to Tesla Powerwalls. But configuring automations still requires YAML files, triggers, conditions, and actions. When your morning routine involves 15 devices across three protocols (Zigbee, Wi-Fi, MQTT), even a simple "good morning" scene becomes a debugging session.
Enter ASI Biont — an AI agent that connects to any device through Python. Instead of writing YAML automations, you describe what you want in natural language. The AI writes the integration code for Home Assistant's REST API, executes it in a sandboxed environment, and returns results. No dashboards, no "add device" buttons — just a chat conversation.
This article shows you how to connect Home Assistant to ASI Biont using its REST API, automate complex routines, and get real-time control without writing a single line of YAML.
Why Connect Home Assistant to an AI Agent?
Home Assistant's native automation engine is powerful but has limits:
- Complex logic — chaining conditions across multiple sensors requires nested templates.
- External data — fetching weather forecasts, stock prices, or train schedules needs custom sensors.
- AI decisions — deciding when to turn off heating based on historical patterns is impossible with simple triggers.
ASI Biont solves these by acting as a "brain" that:
1. Reads sensor data from Home Assistant via REST API.
2. Analyzes it using Python libraries (pandas, numpy) for trend detection.
3. Sends commands back to Home Assistant to control devices.
4. Provides natural language explanations of every action.
Connection Method: HTTP API via execute_python
ASI Biont uses execute_python — a sandboxed Python environment in the cloud. The AI writes a script that uses aiohttp to call Home Assistant's REST API. You provide:
- Home Assistant URL (e.g., http://192.168.1.100:8123)
- Long-Lived Access Token (generated in Home Assistant → your profile → security)
The script runs up to 30 seconds, sends requests, and returns results. No permanent connection needed — you call the AI when you need something done.
Why not MQTT or SSH? Home Assistant has a well-documented REST API (https://developers.home-assistant.io/docs/api/rest/). It's simple, secure, and requires no extra software. MQTT works too, but REST is easier for ad-hoc commands.
Real-World Scenario: Smart Energy Saving with AI
Problem: Maria's electricity bill is $250/month. She has a heat pump, smart plugs for the water heater and dryer, and a temperature sensor in each room. She wants the AI to:
- Turn off the water heater when nobody is home
- Pre-heat the living room before she arrives
- Shift the dryer cycle to off-peak hours (after 10 PM)
- Alert her if any room's temperature drops below 60°F (15°C) while the heat pump is on
Solution with ASI Biont: Maria opens the chat and describes her setup. The AI generates a Python script that:
import aiohttp
import asyncio
from datetime import datetime
HOME_ASSISTANT_URL = "http://192.168.1.100:8123"
TOKEN = "your_long_lived_token_here"
async def call_api(endpoint, method="GET", data=None):
headers = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json"
}
async with aiohttp.ClientSession() as session:
url = f"{HOME_ASSISTANT_URL}/api/{endpoint}"
if method == "GET":
async with session.get(url, headers=headers) as resp:
return await resp.json()
elif method == "POST":
async with session.post(url, headers=headers, json=data) as resp:
return await resp.json()
async def check_occupancy():
# Get all person entities
persons = await call_api("states")
home_count = 0
for state in persons:
if state['entity_id'].startswith('person.'):
if state['state'] == 'home':
home_count += 1
return home_count > 0 # True if someone is home
async def main():
someone_home = await check_occupancy()
if not someone_home:
# Turn off water heater
await call_api("services/switch/turn_off", method="POST", data={
"entity_id": "switch.water_heater"
})
print("Water heater turned off — nobody home")
else:
# Check living room temperature
temp = await call_api("states/sensor.living_room_temperature")
current_temp = float(temp['state'])
if current_temp < 18: # Below 18°C (64°F)
await call_api("services/climate/set_temperature", method="POST", data={
"entity_id": "climate.heat_pump",
"temperature": 21
})
print(f"Living room temp {current_temp}°C — heat pump set to 21°C")
# Check if it's after 10 PM for off-peak dryer
now = datetime.now()
if now.hour >= 22:
dryer_state = await call_api("states/switch.dryer")
if dryer_state['state'] == 'off':
await call_api("services/switch/turn_on", method="POST", data={
"entity_id": "switch.dryer"
})
print("Dryer started — off-peak hours")
asyncio.run(main())
Results:
- Water heater runs only when someone is home — saves $30/month
- Living room always warm before Maria arrives
- Dryer automatically shifts to off-peak — $0.10/kWh vs $0.25/kWh
- AI alerts via Telegram if temperature drops unexpectedly
Step-by-Step: How to Connect Home Assistant to ASI Biont
1. Generate a Long-Lived Access Token in Home Assistant
- Go to your Home Assistant instance → user profile (bottom left) → Security → Long-Lived Access Tokens
- Click "Create Token", give it a name (e.g., "ASI Biont"), copy the token immediately
2. Open ASI Biont Chat
- Go to asibiont.com and start a new conversation
- Describe what you want: "Connect to my Home Assistant at 192.168.1.100:8123 with this token"
- Paste the token
3. Describe Your Task
Example: "Check if anyone is home. If not, turn off the water heater and set the heat pump to eco mode. If yes, and living room temperature is below 18°C, turn on heating."
The AI will:
- Write the Python script using aiohttp
- Execute it in the sandbox (30-second timeout)
- Return the results (e.g., "Water heater turned off. Nobody home.")
4. Iterate
You can ask follow-ups: "Now also turn on the porch light at sunset" — the AI will modify the script and re-run it.
Why This Beats Native Home Assistant Automations
| Feature | Home Assistant YAML | ASI Biont AI Agent |
|---|---|---|
| Setup time | 30 minutes writing code | 2 minutes describing in chat |
| Complex logic | Requires Jinja2 templates | Natural language + Python |
| External data | Custom REST sensor | Any Python library (requests, pandas) |
| Debugging | Manual log checking | AI explains errors in plain English |
| Flexibility | Limited to built-in triggers | Any Python logic, any library |
Other Integration Scenarios
Scenario 1: Security Alert System
# AI-generated script: monitor door sensors and send SMS if opened at night
async def check_doors():
doors = ["binary_sensor.front_door", "binary_sensor.back_door"]
for door in doors:
state = await call_api(f"states/{door}")
if state['state'] == 'on': # door open
print(f"ALERT: {door} opened at {datetime.now()}")
# Send via Telegram (using requests)
import requests
requests.post(f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage",
json={"chat_id": CHAT_ID, "text": f"Door opened at {datetime.now()}"})
Scenario 2: Energy Dashboard with AI Analysis
Ask: "Show me which devices used the most electricity in the last 7 days"
The AI will:
- Fetch sensor history from Home Assistant API (/api/history/period)
- Parse JSON, calculate totals using pandas
- Return a summary: "Your heat pump used 120 kWh, dryer 45 kWh, water heater 60 kWh — total 225 kWh, $56.25 at $0.25/kWh"
Scenario 3: Voice-Controlled Automation (via API)
You can integrate ASI Biont with a voice assistant (e.g., Alexa via emulated Hue) or a custom Telegram bot. The AI generates a script that listens for commands via Telegram webhook and calls Home Assistant API.
Conclusion: Your Smart Home, Now Actually Smart
Home Assistant is the best open-source platform for device control. But automation logic is still manual. ASI Biont fills the gap by bringing AI-powered decision making into your smart home. You don't need to learn YAML, Jinja2 templates, or REST API endpoints — just describe what you want.
The integration works today, with any Home Assistant instance (version 2024.1+ recommended). No additional hardware, no cloud subscription for the bridge — just the AI agent and your home network.
Try it yourself: Go to asibiont.com, start a chat, and tell the AI: "Connect to my Home Assistant at 192.168.1.100:8123. Turn on the kitchen lights if the motion sensor detects movement after sunset." The AI will write and execute the code in seconds.
Your smart home is about to get a lot smarter.
Comments