Control Home Assistant devices and automate via the REST API and WebSocket API

domain: home-assistant.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Generate a Long-Lived Access Token in the Home Assistant user profile page; all API calls require the header Authorization: Bearer <TOKEN>
  2. Test connectivity with GET http://<ha-host>:8123/api/ which returns {"message":"API running"} if the HTTP integration is enabled and the token is valid
  3. Control entities via POST http://<ha-host>:8123/api/services/<domain>/<service> with a JSON body such as {"entity_id":"light.living_room"}; for example POST /api/services/light/turn_on with {"entity_id":"light.x","brightness":200}
  4. Subscribe to state changes in real time using the WebSocket API: connect to ws://<ha-host>:8123/api/websocket, respond to the auth_required message with {"type":"auth","access_token":"<TOKEN>"}, then send a subscribe_events command
  5. Retrieve the current state of an entity with GET /api/states/<entity_id>; retrieve all states with GET /api/states; use the state object's attributes map for entity-specific properties (color, brightness, temperature, etc.)
  6. Trigger automations or scripts directly via the services API: POST /api/services/automation/trigger with {"entity_id":"automation.<name>"} or POST /api/services/script/turn_on

Known gotchas

Related routes

Call the Home Assistant WebSocket API to subscribe to state change events and trigger services programmatically
home-assistant.io · 6 steps · unrated
Trigger a Home Assistant automation from an external IoT service using a webhook
home-assistant.io · 6 steps · unrated
Process a natural-language command with Home Assistant's Conversation API
iot · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans