Home Assistant gives you control over 2,500+ device integrations. OpenClaw gives you an AI agent you can talk to. Connect them and you get a voice-controlled smart home that works through the messaging app you already use.
This guide shows you how to build an OpenClaw Home Assistant skill from scratch. You’ll learn how to set up the API connection, write the SKILL.md configuration, and build practical automations for lights, thermostats, locks, and sensors. By the end, you’ll be controlling your entire smart home through conversations with your Moltbot agent.
Already using Home Assistant? You’re halfway there. New to both? Start with our Getting Started guide to install OpenClaw first, then come back here to add Home Assistant integration.
What You’re Building
An OpenClaw skill that connects to your Home Assistant instance and lets you control devices through natural language. The setup uses Home Assistant’s REST API and a Long-Lived Access Token for authentication.
What you’ll be able to do:
- Turn lights on/off, adjust brightness and color
- Set thermostats and check temperature readings
- Lock/unlock smart locks
- Check sensor states (doors, motion, temperature, humidity)
- Run scenes and automations
- Query device status across your entire smart home
The skill works through any OpenClaw messaging channel — Telegram, WhatsApp, Discord, or Signal. One agent, all your devices.
Prerequisites
Three things before you start:
-
OpenClaw installed and running If you haven’t set up OpenClaw yet, follow the installation guide. You need a working Moltbot agent connected to at least one messaging channel.
-
Home Assistant instance running You need Home Assistant set up and accessible on your network. Can be Home Assistant OS, Container, Core, or Supervised. As long as it’s running and you can reach the web interface, you’re good.
-
Network access between OpenClaw and Home Assistant Your OpenClaw instance needs to reach Home Assistant’s API. If both run on the same network, this is automatic. If Home Assistant is remote, you’ll need the URL and proper firewall rules.
Step 1: Generate a Home Assistant Long-Lived Access Token
Home Assistant uses Long-Lived Access Tokens for API authentication. Creating one takes three steps.
Open Your Profile
Log into your Home Assistant web interface. Click your username in the bottom left corner, then click “Profile.”
Create the Token
Scroll down to “Long-Lived Access Tokens” and click “Create Token.”
Give it a name like “OpenClaw” so you know what it’s for later. Click “OK.”
Home Assistant displays the token once. Copy it immediately — you won’t be able to see it again.
Save the Token
Store the token in your OpenClaw configuration:
openclaw config set home-assistant.token YOUR_TOKEN_HERE
Or set it as an environment variable:
export HOMEASSISTANT_TOKEN=your_token_here
Step 2: Find Your Home Assistant URL
You need the full URL to your Home Assistant instance. This is usually:
http://homeassistant.local:8123(local network, default)http://192.168.1.100:8123(local network, static IP)https://your-subdomain.duckdns.org(remote access via DuckDNS)https://your-domain.com(custom domain with SSL)
Test the URL by opening it in a browser. If you see the Home Assistant login page, the URL is correct.
Save it in your OpenClaw config:
openclaw config set home-assistant.url "http://homeassistant.local:8123"
Step 3: Test the API Connection
Before building the skill, verify the API works. Use curl to test:
curl -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
http://homeassistant.local:8123/api/states
Replace YOUR_TOKEN with your Long-Lived Access Token and the URL with your Home Assistant URL.
If the connection works, you’ll get a JSON array of all your device states. If you get a 401 error, check your token. If you get a connection error, verify your URL and network access.
Step 4: Create the Home Assistant Skill Directory
OpenClaw skills live in ~/.openclaw/skills/. Create a directory for your Home Assistant skill:
mkdir -p ~/.openclaw/skills/home-assistant
Step 5: Write the SKILL.md File
Create ~/.openclaw/skills/home-assistant/SKILL.md with this content:
# Home Assistant Control
> Control Home Assistant devices and automations through natural language.
## Description
This skill integrates with Home Assistant's REST API to control smart home
devices. It can turn lights on/off, adjust thermostats, lock doors, check
sensor states, and run scenes. The skill uses the Home Assistant Long-Lived
Access Token stored in the OpenClaw configuration.
## Configuration
Requires two environment variables:
- `HOMEASSISTANT_TOKEN` - Long-Lived Access Token from Home Assistant
- `HOMEASSISTANT_URL` - Full URL to your Home Assistant instance (e.g., http://homeassistant.local:8123)
Set them with:
openclaw config set home-assistant.token YOUR_TOKEN openclaw config set home-assistant.url YOUR_URL
## Triggers
Use this skill when the user:
- Asks to control a light, switch, or device
- Requests temperature or sensor readings
- Wants to run a scene or automation
- Asks about the state of any smart home device
- Says things like "turn on the living room lights" or "lock the front door"
## API Integration
### Get All Device States
GET {HOMEASSISTANT_URL}/api/states Headers: Authorization: Bearer {HOMEASSISTANT_TOKEN}
Returns array of all entities with their current states.
### Call a Service
POST {HOMEASSISTANT_URL}/api/services/{domain}/{service} Headers: Authorization: Bearer {HOMEASSISTANT_TOKEN} Body: {“entity_id”: “light.living_room”}
Common service calls:
- `light/turn_on` - Turn on a light
- `light/turn_off` - Turn off a light
- `climate/set_temperature` - Set thermostat temperature
- `lock/lock` - Lock a smart lock
- `lock/unlock` - Unlock a smart lock
- `scene/turn_on` - Activate a scene
- `automation/trigger` - Trigger an automation
### Control Light with Brightness
POST {HOMEASSISTANT_URL}/api/services/light/turn_on Body: {“entity_id”: “light.bedroom”, “brightness”: 128}
Brightness range: 0-255
### Control Light with Color
POST {HOMEASSISTANT_URL}/api/services/light/turn_on Body: {“entity_id”: “light.bedroom”, “rgb_color”: [255, 0, 0]}
RGB values: 0-255 for each channel
### Set Thermostat Temperature
POST {HOMEASSISTANT_URL}/api/services/climate/set_temperature Body: {“entity_id”: “climate.living_room”, “temperature”: 72}
## Entity ID Pattern
Home Assistant entities follow the pattern `{domain}.{object_id}`:
- Lights: `light.living_room`, `light.bedroom_lamp`
- Switches: `switch.coffee_maker`, `switch.fan`
- Climate: `climate.thermostat`, `climate.living_room`
- Locks: `lock.front_door`, `lock.garage`
- Sensors: `sensor.temperature`, `sensor.humidity`
- Scenes: `scene.movie_time`, `scene.good_night`
When the user refers to a device by name, map it to the correct entity_id
by checking the available entities first.
## Behavior
1. **Find the device first** - Before calling a service, get all states to
find the correct entity_id. Match the user's description to entity names.
2. **Be specific with entity IDs** - If the user says "living room light"
and you find `light.living_room`, use that exact entity_id.
3. **Handle ambiguity** - If multiple entities match the description (e.g.,
"bedroom light" could match `light.bedroom_ceiling` and `light.bedroom_lamp`),
ask which one the user means.
4. **Confirm actions** - After calling a service, confirm what happened.
"Living room lights turned on" or "Front door locked."
5. **Report failures clearly** - If a service call fails, explain why.
Don't just say "error" -- say "Could not turn on the lights. The device
might be offline."
6. **Use natural units** - When setting temperature, ask the user's preference
(Fahrenheit/Celsius) and convert if needed. Home Assistant stores in the
configured unit system.
7. **Handle brightness intuitively** - If the user says "dim the lights,"
set brightness to around 30-50. "Bright" means 200-255. "Medium" is 100-150.
## Output Format
Keep responses conversational and concise:
- "Living room lights turned on"
- "Thermostat set to 72°F"
- "Front door is locked"
- "Bedroom temperature: 68°F, humidity: 45%"
Don't add unnecessary details like "I've successfully completed your request
to turn on the living room lights." Just confirm the action.
## Examples
**User:** "Turn on the living room lights"
**Response:** Get states, find `light.living_room`, call `light/turn_on`,
confirm "Living room lights turned on."
**User:** "Set the thermostat to 70"
**Response:** Find `climate.*` entity, call `climate/set_temperature` with
temperature 70, confirm "Thermostat set to 70°F."
**User:** "Dim the bedroom lights"
**Response:** Find `light.bedroom*`, call `light/turn_on` with brightness 64,
confirm "Bedroom lights dimmed."
**User:** "Is the front door locked?"
**Response:** Get states, find `lock.front_door`, check state, respond
"Yes, the front door is locked" or "No, the front door is unlocked."
**User:** "What's the temperature in the living room?"
**Response:** Get states, find `sensor.living_room_temperature`, return the
current value "Living room temperature: 72°F."
Save this file and move to the next step.
Step 6: Reload and Test Your Skill
Reload your OpenClaw skills to load the new Home Assistant integration:
openclaw skills reload
Verify it loaded:
openclaw skills list
You should see home-assistant in the output.
Test with Basic Commands
Open your messaging app (or use openclaw chat for terminal testing) and try:
Turn on the living room lights
If everything is configured correctly, your agent will query Home Assistant, find the light entity, and turn it on. You should get a confirmation message.
Try a few more:
What's the temperature?
Lock the front door
Set the thermostat to 68
Troubleshooting
“Could not connect to Home Assistant”
- Check your URL is correct:
openclaw config get home-assistant.url - Verify Home Assistant is running and accessible
- Test the API manually with curl (Step 3)
“Authorization failed”
- Check your token is correct:
openclaw config get home-assistant.token - Generate a new token in Home Assistant if needed
“Entity not found”
- The agent couldn’t map your device name to an entity_id
- Check your entity names in Home Assistant (Developer Tools > States)
- Be more specific in your command (use the exact entity name)
Building Practical Automations
Once the basic skill works, you can extend it with more complex automations and scenes.
Scene Control
Home Assistant scenes let you set multiple devices to specific states with one command. Create a scene in Home Assistant (Configuration > Scenes), then control it through OpenClaw:
Activate movie time scene
Run good night scene
Your skill will call scene/turn_on with the appropriate entity_id.
Multi-Device Control
You can control multiple devices in one command by having the agent parse the request and make multiple API calls:
Turn off all the lights
Set all thermostats to 70
Lock all the doors
The agent queries all states, filters by domain (light, climate, lock), and calls the service for each matching entity.
Conditional Logic
Build conditional automations into your SKILL.md:
## Smart Behavior
When the user says "I'm leaving," perform these actions:
1. Turn off all lights
2. Set thermostat to 65°F (eco mode)
3. Lock all doors
4. Confirm each action
When the user says "I'm home," perform these actions:
1. Turn on entry lights
2. Set thermostat to 72°F
3. Unlock the front door
4. Confirm each action
The agent will execute these multi-step workflows when triggered by the right phrase.
Sensor Monitoring
Read sensor data and respond intelligently:
What's the humidity in the basement?
Is anyone in the living room? (motion sensor)
Are any doors open?
What's the air quality?
The skill queries sensor states and presents the data in readable form.
Advanced Configuration with YAML
Home Assistant’s power comes from its YAML configuration. You can define custom entities, automations, and scripts that your OpenClaw skill can trigger.
Example: Custom Script
Create a script in Home Assistant’s configuration.yaml:
script:
bedtime:
sequence:
- service: light.turn_off
entity_id: all
- service: climate.set_temperature
entity_id: climate.bedroom
data:
temperature: 68
- service: lock.lock
entity_id: lock.front_door
- service: lock.lock
entity_id: lock.back_door
Trigger it from OpenClaw:
Run bedtime script
Your agent calls script/turn_on with entity_id: script.bedtime, and Home Assistant executes the entire sequence.
Example: Custom Automation
Define an automation that your OpenClaw skill can enable/disable:
automation:
- alias: "Motion-Activated Lights"
trigger:
platform: state
entity_id: binary_sensor.living_room_motion
to: "on"
action:
service: light.turn_on
entity_id: light.living_room
Control it through OpenClaw:
Enable motion-activated lights
Disable motion-activated lights
The skill calls automation/turn_on or automation/turn_off with the automation’s entity_id.
Security Considerations
Running a Home Assistant skill means your AI agent has full control over your smart home. Take security seriously.
Protect Your Token
Your Long-Lived Access Token has full administrative access to Home Assistant. If someone gets the token, they control your home.
- Never commit the token to git repositories
- Don’t share it in messages or screenshots
- Store it in OpenClaw’s config system, not in the SKILL.md
- Rotate the token periodically (delete and create a new one)
Network Isolation
If Home Assistant is exposed to the internet (via DuckDNS, Cloudflare Tunnel, etc.), make sure:
- You use HTTPS with valid SSL certificates
- You enable two-factor authentication in Home Assistant
- You limit access to trusted IP addresses if possible
If both OpenClaw and Home Assistant run on the same local network, they don’t need internet exposure. Keep them local-only for maximum security.
Skill Permissions
The SKILL.md you wrote gives your agent control over every Home Assistant entity. If you want to limit what the skill can access, add constraints:
## Restrictions
Only control these entity types:
- Lights (light.*)
- Scenes (scene.*)
Do NOT control:
- Locks (lock.*)
- Garage doors (cover.garage_*)
- Security system (alarm_control_panel.*)
The agent will follow these rules when deciding which API calls to make.
For more on securing self-hosted AI agents, read our ClawHub Security guide.
Extending the Skill
The basic Home Assistant skill covers lights, climate, locks, and sensors. Here are additional features you can add by extending the SKILL.md.
Voice Notifications
If you have TTS (text-to-speech) configured in Home Assistant, add voice announcements:
## TTS Announcements
When the user asks the agent to announce something, use:
POST {HOMEASSISTANT_URL}/api/services/tts/google_say
Body: {"entity_id": "media_player.living_room", "message": "Your message here"}
Then you can say:
Announce that dinner is ready
Cover Control (Blinds, Shades, Garage Doors)
Add cover entity support:
## Cover Control
- `cover/open_cover` - Open blinds, shades, or garage doors
- `cover/close_cover` - Close them
- `cover/stop_cover` - Stop mid-operation
Example: "Open the living room blinds" -> `cover/open_cover` with `entity_id: cover.living_room_blinds`
Media Player Control
Control speakers, TVs, and media players:
## Media Player Control
- `media_player/turn_on` - Turn on a media player
- `media_player/turn_off` - Turn off
- `media_player/media_play_pause` - Toggle playback
- `media_player/volume_set` - Set volume (0.0 to 1.0)
Example: "Play music in the kitchen" -> find media_player.kitchen, call media_player/media_play
Camera Snapshots
Retrieve images from Home Assistant cameras:
## Camera Integration
When the user asks to see a camera, use:
GET {HOMEASSISTANT_URL}/api/camera_proxy/camera.front_door
Return the image to the user through the messaging channel.
Comparing with Other Smart Home Solutions
Home Assistant with OpenClaw gives you something commercial platforms don’t: complete control and privacy. Here’s how it compares.
vs. Alexa/Google Assistant
Alexa and Google Assistant:
- Cloud-dependent (stops working without internet)
- Limited to compatible devices and skills
- Voice data processed on company servers
- Subject to API changes and feature removal
Home Assistant + OpenClaw:
- Works entirely on your local network
- Supports 2,500+ integrations (if it connects to a network, Home Assistant probably supports it)
- All processing happens on your hardware
- You control updates and changes
vs. Apple HomeKit
Apple HomeKit:
- Requires HomeKit-certified devices (smaller ecosystem)
- Locked to Apple devices (iOS, macOS, HomePod)
- Good privacy model but limited device support
Home Assistant + OpenClaw:
- Works with any device Home Assistant supports
- Access from any platform (iOS, Android, desktop, web)
- Can integrate with HomeKit if desired (Home Assistant Bridge)
vs. SmartThings
SmartThings:
- Samsung ecosystem, cloud-dependent
- Good device support but requires their hub
- Automations limited by cloud processing
Home Assistant + OpenClaw:
- No hub lock-in (works with Zigbee, Z-Wave, WiFi, anything)
- Local processing means automations are instant
- YAML configuration means infinite automation possibilities
The tradeoff is setup complexity. Alexa works out of the box. Home Assistant + OpenClaw requires the setup you just completed. But once it’s running, you own the entire stack.
Real-World Usage Examples
Here are automations we actually use in production with OpenClaw and Home Assistant.
Morning Routine
Run morning routine
Agent executes:
- Turn on bedroom lights to 30% brightness
- Set thermostat to 72°F
- Start the coffee maker (smart plug)
- Open the bedroom blinds
All defined in a Home Assistant script, triggered by one message.
Security Check
Security check
Agent queries:
- All lock states
- All door/window sensor states
- Garage door state
- Security camera status
Responds with: “All doors locked. Living room window open. Garage closed. Cameras online.”
Climate Control by Room
Make the bedroom cooler
Agent finds bedroom climate entity, reads current temperature, lowers it by 2 degrees, confirms new setting.
Presence-Based Lighting
I'm leaving
Agent turns off all lights, sets thermostats to eco mode, locks doors, arms security system (if configured). One message, entire home secured.
Troubleshooting Common Issues
Skill Doesn’t Recognize Device Names
Home Assistant entity IDs don’t always match friendly names. If your light is named “Living Room Ceiling” in the UI but the entity_id is light.living_room_lamp, the agent might not match them.
Fix: Check entity IDs in Home Assistant (Developer Tools > States) and use those exact names when talking to your agent. Or add a mapping section to your SKILL.md:
## Entity Aliases
- "living room light" maps to `light.living_room_lamp`
- "bedroom lamp" maps to `light.bedroom_side_table`
Services Fail Silently
If a service call doesn’t work but doesn’t produce an error, check Home Assistant’s logs (Settings > System > Logs). The API might be returning 200 OK but the service call failed internally.
Common causes:
- Device is offline or unavailable
- Service doesn’t support the entity type
- Missing required parameters (e.g., color on a non-RGB light)
High API Latency
If commands take several seconds to execute, check network latency between OpenClaw and Home Assistant. If they’re on the same network, latency should be under 100ms.
Fixes:
- Use local URLs (
http://homeassistant.local:8123) not remote ones - Check WiFi signal strength for both machines
- Verify no firewall or routing issues
Token Expiration
Long-Lived Access Tokens don’t expire automatically, but they can be revoked. If your skill stops working with authorization errors, check that the token still exists in Home Assistant (Profile > Long-Lived Access Tokens).
If it’s gone, generate a new one and update your OpenClaw config.
FAQ
Can I use this with Home Assistant Cloud (Nabu Casa)?
Yes. If you subscribe to Home Assistant Cloud, you can use the cloud URL instead of a local one. Just set HOMEASSISTANT_URL to your Home Assistant Cloud address. The Long-Lived Access Token works the same way.
Does this work with HASS.io, Home Assistant OS, or Core?
Yes. The skill uses the REST API, which is available in all Home Assistant installation types. As long as you can access the web interface, the API works.
Can I control Home Assistant from outside my home network?
Yes, but you need to expose Home Assistant to the internet (via DuckDNS, Cloudflare Tunnel, or a VPN). Use HTTPS and strong authentication. We recommend a VPN for security — expose Home Assistant only to your VPN network, not the public internet.
How many API calls does this generate?
Each command typically makes 2-3 API calls: one to get all states (for entity discovery), one to call the service, and sometimes one to verify the result. Home Assistant’s API is fast, so this doesn’t create noticeable delays.
Can I run multiple Home Assistant instances?
Yes. Create separate skills (e.g., home-assistant-house, home-assistant-cabin) with different tokens and URLs. Each skill manages one Home Assistant instance.
Does this replace Home Assistant automations?
No. Home Assistant’s built-in automations run locally and trigger instantly based on state changes. The OpenClaw skill is for on-demand control through conversation. Use both: automations for automatic actions, the OpenClaw skill for manual control.
What happens if Home Assistant is offline?
API calls will fail, and the skill will report that it can’t connect. Your OpenClaw agent continues working for everything else; only Home Assistant control is affected.
Summary
| Step | Action | Details |
|---|---|---|
| 1 | Generate token | Create Long-Lived Access Token in Home Assistant Profile settings |
| 2 | Save credentials | Store token and URL in OpenClaw config |
| 3 | Test API | Verify connection with curl before building the skill |
| 4 | Create skill | mkdir -p ~/.openclaw/skills/home-assistant |
| 5 | Write SKILL.md | Add API integration, triggers, and behavior rules |
| 6 | Reload | openclaw skills reload |
| 7 | Test | Control devices through your messaging app |
You now have full smart home control through your OpenClaw agent. 2,500+ Home Assistant integrations, accessible through natural language conversation in Telegram, WhatsApp, Discord, or Signal.
Start with basic commands (lights on/off, check temperature). Build up to scenes and multi-device automations. Define YAML scripts in Home Assistant and trigger them with one message. The more you use it, the more automations you’ll think of.
For more OpenClaw integrations, check out the Best Skills of 2026 or browse the Smart Home category on Claw Directory. If you want to publish your Home Assistant skill for others to use, read How to Build OpenClaw Skills for the full publishing process.