For the last week, we’ve been building a digital brain. We’ve given OpenClaw the ability to see, hear, speak, and remember. But so far, it’s been trapped in the machine. Today, we break the fourth wall.
Today, we connect OpenClaw to the physical world using Home Assistant.
Home Assistant is the gold standard for local smart home control. By integrating it, our agent stops being just a chatbot and starts becoming a true house majordomo—capable of checking the thermostat, arming the security system, or turning off the lights when I forget.
The Architecture
The integration is surprisingly simple. Home Assistant exposes a robust REST API. All our agent needs is a URL and a Long-Lived Access Token.
We store these credentials securely in our TOOLS.md or environment variables:
HASS_URL="http://192.168.1.167:8123"
HASS_TOKEN="eyJhbGciOiJIUzI1Ni..."
Building the Skill
Instead of a complex Python library, we built a lightweight shell script wrapper (hass.sh) that OpenClaw can execute directly. This keeps the agent fast and flexible.
Here is the core logic:
#!/bin/bash
# hass.sh - Simple wrapper for Home Assistant API
CMD=$1
ENTITY=$2
DATA=$3
case "$CMD" in
"state")
curl -s -H "Authorization: Bearer $HASS_TOKEN" \
"$HASS_URL/api/states/$ENTITY"
;;
"call")
DOMAIN=$2
SERVICE=$3
ENTITY=$4
PAYLOAD="{\"entity_id\": \"$ENTITY\"}"
if [ ! -z "$5" ]; then
# Merge optional JSON data
PAYLOAD=$(echo "$PAYLOAD" | jq -s '.[0] * .[1]' - <(echo "$5"))
fi
curl -s -X POST -H "Authorization: Bearer $HASS_TOKEN" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"$HASS_URL/api/services/$DOMAIN/$SERVICE"
;;
*)
echo "Usage: ./hass.sh [state|call] ..."
;;
esac
What Can It Do?
With this simple script, OpenClaw has full command over the house. I’ve mapped out the critical entities in the skill documentation so the agent knows what’s available:
- Security: Arm/Disarm Blink cameras (
alarm_control_panel.blink_55_outdoor) - Climate: Check Govee temperature/humidity sensors (
sensor.h5075_f946_temperature) - Lighting: Toggle plugs and lights (
switch.plug2_1) - Presence: Check if I’m home (
person.james_tang)
The Agent Experience
The magic happens when you combine this with natural language.
User: “I’m leaving for the day. Lock it down.”
Agent (Reasoning):
- User is leaving.
- Action required: Arm security system, turn off lights.
- Tool call:
exec ./hass.sh call alarm_control_panel alarm_arm_away alarm_control_panel.blink_55_indoor - Tool call:
exec ./hass.sh call switch turn_off switch.plug2_1
Agent (Reply): “Done. Indoor cameras armed and the office plug is off. Have a good day.”
Why Local Matters
Just like with Ollama (Day 5), the key here is local control. This entire interaction happens on my local network. My voice command goes to the agent on the Pi, which hits the Home Assistant API on the local IP. No cloud lag, no privacy leaks.
Next Steps
Now that the agent controls the environment, we need to make it watch the markets. Tomorrow, we build The Watchdog—a financial analyst agent that tracks crypto and stocks.