Home Assistant AI Bot Integration
Connect OpenClaw or OpenClaw to Home Assistant for intelligent home automation. Control your smart home with natural language via Discord or Telegram.
Overview
Integrating an AI chatbot with Home Assistant transforms how you interact with your smart home. Instead of navigating apps or remembering commands, simply message your bot: "Turn off the living room lights" or "What's the temperature downstairs?"
Architecture
User Message (Discord/Telegram/WhatsApp)
↓
[Your VPS - OpenClaw/OpenClaw]
↓
[Home Assistant API]
↓
Smart Home Devices
Your VPS acts as the AI gateway, processing natural language and translating it to Home Assistant commands.
Prerequisites
- VPS running OpenClaw or OpenClaw
- Home Assistant instance (local or cloud)
- Home Assistant Long-Lived Access Token
- Basic familiarity with Home Assistant entities
Setup Options
Option 1: Home Assistant on Same VPS
Run Home Assistant alongside your bot:
# Install Home Assistant Container
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-v /opt/homeassistant:/config \
-p 8123:8123 \
ghcr.io/home-assistant/home-assistant:stable
Pros: Single server, low latency Cons: More resource usage, limited device access
Option 2: Connect to Existing Home Assistant
Connect your VPS bot to Home Assistant running elsewhere:
# In your bot's .env file
HOME_ASSISTANT_URL=https://your-ha-instance.duckdns.org:8123
HOME_ASSISTANT_TOKEN=your-long-lived-access-token
Pros: Full device access, existing setup preserved Cons: Requires port forwarding or Nabu Casa
Getting Your Home Assistant Token
- Open Home Assistant
- Click your profile (bottom left)
- Scroll to "Long-Lived Access Tokens"
- Create Token → Name it "OpenClaw Bot"
- Copy and save the token immediately
Bot Configuration
System Prompt for Home Assistant
You are a helpful smart home assistant. You can control devices through Home Assistant.
Available commands:
- Turn on/off lights: Use entity IDs like light.living_room
- Adjust temperature: Use climate.thermostat
- Check sensors: Use sensor.temperature_living_room
- Control media: Use media_player.living_room_tv
Always confirm actions you take. If unsure about an entity, ask for clarification.
Example .env Configuration
# AI Provider
ANTHROPIC_API_KEY=your-key
# Home Assistant
HOME_ASSISTANT_ENABLED=true
HOME_ASSISTANT_URL=http://homeassistant.local:8123
HOME_ASSISTANT_TOKEN=eyJ0...long-token...
# Allowed entities (security)
HA_ALLOWED_DOMAINS=light,switch,climate,sensor
HA_BLOCKED_ENTITIES=lock.front_door,alarm_control_panel
Security Considerations
Never Allow Unrestricted Access
Limit which entities the bot can control:
# Only allow specific domains
HA_ALLOWED_DOMAINS=light,switch,climate,media_player,sensor
# Block sensitive entities
HA_BLOCKED_ENTITIES=lock.*,alarm_control_panel.*,cover.garage_*
Use a Dedicated User
Create a Home Assistant user specifically for the bot with limited permissions.
Network Security
If Home Assistant is local:
- Use VPN (WireGuard/Tailscale) to connect VPS
- Never expose HA directly to internet without Nabu Casa
- Use HTTPS with valid certificates
Example Interactions
Lighting Control
User: "Turn off all the lights downstairs" Bot: "I've turned off 4 lights in the downstairs area: living room ceiling, living room lamp, kitchen main, and hallway."
Climate Check
User: "Is it too hot upstairs?" Bot: "The upstairs temperature is currently 24°C. The thermostat is set to 21°C. Would you like me to turn on the AC?"
Status Report
User: "Give me a house status" Bot: "Here's your home status:
- Temperature: Living room 21°C, Bedroom 19°C
- Lights: 3 on (office, porch, bathroom)
- Doors: All locked
- Energy today: 12.4 kWh"
Automation Ideas
Natural Language Scenes
Instead of buttons, use natural language:
- "Movie time" → Dims lights, turns on TV, closes blinds
- "Goodnight" → Locks doors, turns off lights, sets alarm
- "Working from home" → Adjusts office temperature, turns on desk lamp
Proactive Notifications
Set up automations to notify via your bot:
# Home Assistant automation
automation:
- alias: "Notify bot of motion"
trigger:
- platform: state
entity_id: binary_sensor.front_door_motion
to: "on"
action:
- service: notify.discord_bot
data:
message: "Motion detected at front door"
Voice Control Chain
Voice Assistant → Discord → Your VPS → Home Assistant → Devices
This allows voice control from anywhere, not just at home.
VPS Requirements
Running Home Assistant integration:
| Component | Minimum | Recommended | |-----------|---------|-------------| | RAM | 2GB | 4GB | | CPU | 2 cores | 4 cores | | Storage | 40GB | 60GB |
If running HA on same VPS, add:
- +1GB RAM for Home Assistant
- +10GB storage for HA database
Troubleshooting
Bot can't connect to Home Assistant
# Test connection from VPS
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://homeassistant.local:8123/api/states
Commands not working
- Check entity IDs are correct
- Verify token has permissions
- Check HA logs for errors
Slow responses
- Use local API when possible
- Cache frequently-used states
- Limit entity polling frequency
Related Guides
Need Help?
Setting up Home Assistant integration can be complex. Our premium setup service includes Home Assistant configuration and testing.
Need a VPS for Your Bot?
We recommend Hostinger KVM 2 VPS - reliable, fast, and perfect for AI chatbots. Get started with our recommended setup.
Get Hostinger VPSNeed Help With Setup?
Got your VPS? Let us handle the technical work. Professional setup and maintenance for OpenClaw (formerly Clawd.bot).