Get your dream built 10x faster

How to integrate Home Assistant with OpenClaw

We build custom applications 5x faster and cheaper 🚀

Book a Free Consultation
4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Stuck on an error? Book a 30-minute call with an engineer and get a direct fix + next steps. No pressure, no commitment.

How to integrate Home Assistant with OpenClaw

 

Direct answer

 

Create an OpenClaw skill (packaged and configured via ClawHub) that calls Home Assistant’s REST API for commands and state reads, authenticate with a dedicated Home Assistant long‑lived access token or OAuth credential stored securely (ClawHub secret store or environment variables), and use an external webhook receiver or queue when Home Assistant needs to push events to OpenClaw. Keep runtime‑critical state and scheduling outside the agent (database, scheduler, or Home Assistant itself), validate and rotate credentials, and debug by inspecting HTTP responses, agent/ClawHub logs, and Home Assistant logs. Below are practical architecture patterns, concrete REST examples you can run now, code snippets, security notes, and a checklist to get you to production.

 

Architecture overview

 
  • Direction 1 — OpenClaw → Home Assistant: The skill makes authenticated REST calls to Home Assistant to call services or read states. This is simple and stateless; the agent must have network access to HA’s API.
  • Direction 2 — Home Assistant → OpenClaw: Home Assistant sends events (webhooks, automations) to a public endpoint you control. That endpoint validates the webhook and then triggers the skill via your ClawHub/agent orchestration mechanism.
  • Where state lives: Put durable or production-critical state outside the agent runtime (database, Home Assistant entities, or external storage). The agent should be ephemeral and stateless whenever possible.

 

Prerequisites

 
  • Home Assistant reachable from your OpenClaw runtime (either via LAN address or a secure URL).
  • A Home Assistant long‑lived access token or OAuth credentials for a dedicated user with limited permissions.
  • ClawHub account and the ability to register and deploy a skill (packaging and config through ClawHub).
  • A secure place to store secrets (ClawHub secret store or environment variables only visible to the runtime).

 

Home Assistant REST basics (real, usable calls)

 
  • Get entity state:
    curl -s \\
      -H "Authorization: Bearer YOUR_LONG_LIVED\_TOKEN" \\
      -H "Content-Type: application/json" \\
      "http://homeassistant.local:8123/api/states/sensor.temperature"
    
  • Call a service (turn on a light):
    curl -X POST \\
      -H "Authorization: Bearer YOUR_LONG_LIVED\_TOKEN" \\
      -H "Content-Type: application/json" \\
      -d '{"entity_id":"light.living_room"}' \\
      "http://homeassistant.local:8123/api/services/light/turn\_on"
    

 

Step‑by‑step: implement a simple OpenClaw skill that toggles a light

 
  • 1) Prepare a Home Assistant token
    • Create a dedicated user in Home Assistant and generate a long‑lived access token from that user’s profile. Record that token securely; it behaves like a password.
  • 2) Store the token securely for the skill
    • Put the token into ClawHub’s secret store or as an environment variable in your skill deployment configuration: e.g., HA\_TOKEN.
  • 3) Write skill code that uses the token to call HA
    • Below is a minimal Node.js example using the standard fetch API. Adapt entry function name to how ClawHub expects skill entrypoints.
  • 4) Package and deploy via ClawHub
    • Upload the skill bundle and configuration to ClawHub. Configure the environment variable HA\_TOKEN and the runtime network access to reach Home Assistant.
  • 5) Test locally and via runtime
    • Test with curl first, then invoke the deployed skill using whatever invocation mechanism ClawHub provides to execute the skill.

 

Minimal Node.js skill example (call Home Assistant service)

 
// <b>//</b> Minimal skill that calls Home Assistant to turn on a light
// <b>//</b> Assumes HA_TOKEN and HA_BASE_URL are provided in environment

const HA_BASE_URL = process.env.HA_BASE_URL || 'http://homeassistant.local:8123';
const HA_TOKEN = process.env.HA_TOKEN;

async function callHomeAssistantService(domain, service, body) {
  const url = `${HA_BASE_URL}/api/services/${domain}/${service}`;
  const res = await fetch(url, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${HA_TOKEN}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(body)
  });
  if (!res.ok) {
    const text = await res.text();
    throw new Error(`HA service call failed: ${res.status} ${text}`);
  }
  return await res.json();
}

// <b>//</b> Exported handler — adapt name to ClawHub entrypoint
module.exports.invoke = async function(payload) {
  // <b>//</b> payload should contain entity_id
  const entity = payload.entity_id || 'light.living_room';
  return await callHomeAssistantService('light', 'turn_on', { entity_id: entity });
};

 

Incoming webhooks: validating and forwarding to OpenClaw

 
  • Pattern: Home Assistant → public webhook endpoint (your server) → validate → call into ClawHub/skill invocation.
  • Why external receiver: OpenClaw agent runtimes are usually not suitable to host public endpoints directly; use a small web server, cloud function, or API gateway so you can validate, queue, and retry reliably.
  • Security: Use a secret token in the webhook URL or include an HMAC header. Verify the token/HMAC before invoking the skill. Limit allowed source IPs if possible.

 

Auth, secrets, and least privilege

 
  • Create a dedicated Home Assistant user with only the needed permissions (only control specific entities).
  • Prefer long‑lived token for server-to-server calls; rotate periodically and have a revocation plan.
  • Store the token in ClawHub secrets or as an environment variable readable only by the skill runtime.
  • Never hardcode tokens into source code or public repos.

 

Production concerns and reliability

 
  • Retries and backpressure: Put an external queue (Redis, SQS, Pub/Sub) between webhooks and the agent if you expect spikes or need guaranteed delivery.
  • State and scheduling: Use Home Assistant entities or an external database for persistent schedules, user preferences, or audit trails. Don’t rely on ephemeral agent memory.
  • Rate limits and timeouts: Handle 429s and transient errors from Home Assistant with exponential backoff. Configure timeouts on HTTP calls.
  • Network topology: If HA is on a private LAN, run the skill runtime within the same network or expose HA through a secure tunnel (NGROK-like solutions or VPN) and secure that access appropriately.

 

Debugging checklist

 
  • Reproduce the call with curl (use the same token and URL) to separate agent vs HA problems.
  • Inspect HTTP status codes and body; 401/403 → credential or scope problem; 404 → wrong endpoint; 500 → HA side error.
  • Check ClawHub and skill logs to see the exact outbound request and response.
  • Verify environment variables in the deployed skill match what you tested locally.
  • If using webhooks, validate that your external receiver is reachable and verifies webhook secrets correctly before invoking the skill.

 

Example debug curl calls

 
curl -v \\
  -H "Authorization: Bearer $HA\_TOKEN" \\
  "http://homeassistant.local:8123/api/states/light.living\_room"
curl -v -X POST \\
  -H "Authorization: Bearer $HA\_TOKEN" \\
  -H "Content-Type: application/json" \\
  -d '{"entity_id":"light.living_room"}' \\
  "http://homeassistant.local:8123/api/services/light/turn\_on"

 

Final checklist before you flip to production

 
  • Token stored in ClawHub secrets or safe environment var.
  • Network path between skill runtime and HA is reliable and secure.
  • Webhook receiver (if used) validates requests and enqueues/forwards events safely.
  • Skill code uses timeouts, retries, and sanitizes inputs from untrusted webhook payloads.
  • Auditing/logging is in place for service calls (who invoked, entity, outcome).

Book Your Free 30‑Minute Migration Call

Speak one‑on‑one with a senior engineer about your no‑code app, migration goals, and budget. In just half an hour you’ll leave with clear, actionable next steps—no strings attached.

Book a Free Consultation

Troubleshooting Home Assistant and OpenClaw Integration

1

Why are OpenClaw devices not discovered by Home Assistant using the OpenClaw integration (mDNS/SSDP discovery)?

OpenClaw devices aren’t discovered by Home Assistant via mDNS/SSDP most often because multicast-based discovery is blocked or isolated: either the OpenClaw agent/runtime or the network prevents multicast UDP (mDNS UDP 5353, SSDP UDP 1900) from reaching Home Assistant, or the device/skill isn’t actually advertising a discovery record.

 

Why discovery fails

 

Common causes:

  • Network isolation — VLANs, different subnets, or router settings block multicast.
  • Runtime isolation — containers, VMs, or OpenClaw agent network namespaces prevent multicast from escaping.
  • Firewall — host or OS blocks UDP 5353/1900.
  • No advertisement — skill/device doesn’t publish correct mDNS/SSDP records or binds only to localhost.

 

How to debug and fix

 
  • Verify ports — ensure UDP 5353 and 1900 reachable between services.
  • Use tools — tcpdump/wireshark or avahi-browse to see advertisements.
  • Run OpenClaw agent with host networking or fix container network to allow multicast.
  • Check logs — OpenClaw skill logs for bind errors and Home Assistant discovery logs.

2

(2) How to fix "Invalid API key" when adding the OpenClaw REST API integration to Home Assistant?

Direct answer: "Invalid API key" means Home Assistant cannot authenticate to OpenClaw. Usually the key is mistyped, placed into the wrong configuration field, revoked/expired, scoped differently (token vs API key), or the integration is pointed at the wrong URL or blocked by network/TLS. Verify the exact key, endpoint, and header format and test a direct request.

 

Verify basics

 
  • Copy the key exactly (no extra spaces/newlines).
  • Confirm key status in OpenClaw dashboard (not revoked/expired).
  • Use the field the integration expects (API key vs OAuth token).

 

Test and debug

 

Run a direct request from the Home Assistant host:

curl -i -H "Authorization: Bearer <OPENCLAW_API_KEY>" <OPENCLAW_API_URL>/health
  • Check HTTP status and response body for auth errors.
  • Inspect Home Assistant logs and OpenClaw server logs for rejected keys and TLS/network issues.

3

(3) How to resolve TLS/SSL certificate errors when Home Assistant connects to the OpenClaw REST API or OpenClaw Cloud?

A quick direct answer: ensure the TLS certificate presented by the OpenClaw REST endpoint is valid and trusted by the Home Assistant host — correct hostname (SAN), complete chain (including intermediates), and correct system time — or import the CA into Home Assistant’s trust store or point Home Assistant at the CA bundle. Only disable verification (-k) for temporary testing.

 

Quick checks and commands

 

Run these from the Home Assistant host to see the problem:

  • Check handshake and SAN with openssl
  • Test as HA would with curl and a CA file or -k for testing
// show cert chain and SNI
openssl s_client -connect api.example.com:443 -servername api.example.com

// curl using a specific CA or skip verification (testing only)
curl --cacert /config/ca.pem https://api.example.com/
curl -k https://api.example.com/  // testing only

 

Fixes

 
  • Use a CA-signed cert (Let’s Encrypt) with correct SANs.
  • Install intermediates so the chain is complete.
  • Trust private CA by adding its root to the Home Assistant OS/container trust store or mount the CA bundle and configure the integration to use it.
  • Check clock on HA; TLS fails if time is wrong.
  • Only disable verification briefly for debugging; don’t leave -k in production.

4

(4) How to troubleshoot OpenClaw MQTT bridge (claw-mqtt) disconnects and intermittent sensor updates in Home Assistant?

Direct answer: Focus on the MQTT layer (broker reachability, auth, TLS, keepalive, client_id, LWT, QoS/retain), OpenClaw agent/skill logs (claw-mqtt runtime, auth/env vars), Home Assistant entity config (unique IDs, discovery, payload format), and network/container stability. Use broker logs and increased debug logging to correlate disconnects with restarts, rate limits, or resource constraints.

 

Key checks

 
  • Broker: verify uptime, TLS certs, auth, client limits, LWT behavior.
  • Client IDs: ensure uniqueness per connection to avoid forced drops.
  • Keepalive/QoS: adjust keepalive and use QoS 1 for critical sensor updates.
  • Logs: enable debug on claw-mqtt, OpenClaw agent, and broker; correlate timestamps.

 

Fixes to try

 
  • Persistent sessions and retained states to avoid lost updates.
  • Increase keepalive, backoff reconnects, or throttle publish rate from sensors/skills.
  • Move heavy state/store out of agent runtime (external DB/queue) if restarts occur.
Book a Free Consultation

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt


Recognized by the best

Trusted by 600+ businesses globally

From startups to enterprises and everything in between, see for yourself our incredible impact.

RapidDev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with.

They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

Arkady
CPO, Praction
Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost.

He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Donald Muir
Co-Founder, Arc
RapidDev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space.

They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Mat Westergreen-Thorne
Co-CEO, Grantify
RapidDev is an excellent developer for custom-code solutions.

We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Emmanuel Brown
Co-Founder, Church Real Estate Marketplace
Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 

This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Samantha Fekete
Production Manager, Media Production Company
The pSEO strategy executed by RapidDev is clearly driving meaningful results.

Working with RapidDev has delivered measurable, year-over-year growth. Comparing the same period, clicks increased by 129%, impressions grew by 196%, and average position improved by 14.6%. Most importantly, qualified contact form submissions rose 350%, excluding spam.

Appreciation as well to Matt Graham for championing the collaboration!

Michael W. Hammond
Principal Owner, OCD Tech

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.Â