
home-assistant-api
Orchestrates access to the Home Assistant REST API for programmatic control of smart home devices. Routes requests to specialized resource files based on task type - authentication, state management, service calls, entity types, or advanced queries. Provides intelligent decision tables for selecting appropriate endpoints and managing integrations.
- Installs
- 52
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/markpitt/claude-skills --skill home-assistant-api- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads home-assistant-api automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Home Assistant REST API Orchestration Skill
This skill provides access to the Home Assistant REST API for building integrations, automating smart home devices, and managing Home Assistant instances programmatically.
Quick Reference: When to Load Which Resource
| Task | Load Resource |
|---|---|
| Setting up authentication, understanding API basics, HTTP methods | resources/core-concepts.md |
| Querying entity states, updating states, monitoring changes | resources/state-management.md |
| Controlling lights, climate, locks, and other devices | resources/service-reference.md |
| Understanding light, switch, sensor, climate entity types | resources/entity-types.md |
| Server-side template queries, complex filters, aggregations | resources/templates.md |
| System configuration, component discovery, error logs | resources/system-config.md |
| Complete code examples, client libraries, patterns | resources/examples.md |
Orchestration Protocol
Phase 1: Task Analysis
Identify what the user needs to accomplish:
Authentication & Setup?
- Getting started with Home Assistant API
- Creating or managing tokens
- Configuring HTTP clients
→ Load
resources/core-concepts.md
Query or Monitor State?
- "What is the temperature in the kitchen?"
- "Is the front door locked?"
- "Get all lights that are on"
- "Monitor entity changes"
→ Load
resources/state-management.md
Control a Device?
- "Turn on the kitchen light"
- "Set thermostat to 22°C"
- "Lock the front door"
- "Play music on speaker"
→ Load
resources/service-reference.md(then find entity type inresources/entity-types.md)
Understand Entity Types?
- "What attributes does a climate entity have?"
- "What services are available for locks?"
- "How do I control a media player?"
→ Load
resources/entity-types.md
Complex Query or Data Aggregation?
- "Count all lights that are on"
- "Get devices with low battery"
- "Average temperature from all sensors"
- "Conditional logic based on time of day"
→ Load
resources/templates.md
System Management or Discovery?
- "What components are loaded?"
- "What services are available?"
- "Check configuration validity"
- "View error logs"
→ Load
resources/system-config.md
Practical Working Example?
- Code in Python, Node.js, Bash, curl
- Integration patterns
- Error handling
- Multi-entity operations
→ Load
resources/examples.md
Phase 2: Endpoint Selection
Use this decision tree to select the right API endpoint:
Do you need to...
│
├─ GET INFORMATION?
│ ├─ Get one entity's state? → GET /api/states/{entity_id}
│ ├─ Get all entity states? → GET /api/states (then filter)
│ ├─ Get configuration? → GET /api/config
│ ├─ List available services? → GET /api/services
│ ├─ Discover event types? → GET /api/events
│ ├─ Query historical data? → GET /api/history/period/{timestamp}
│ ├─ Get error log? → GET /api/error_log
│ ├─ Complex query/computation? → POST /api/template
│ └─ Check system status? → GET /api/
│
├─ CONTROL A DEVICE?
│ ├─ Light (on/off/brightness)? → POST /api/services/light/{service}
│ ├─ Switch? → POST /api/services/switch/{service}
│ ├─ Climate/thermostat? → POST /api/services/climate/{service}
│ ├─ Lock? → POST /api/services/lock/{service}
│ ├─ Cover/blinds? → POST /api/services/cover/{service}
│ ├─ Media player? → POST /api/services/media_player/{service}
│ ├─ Fan? → POST /api/services/fan/{service}
│ ├─ Camera? → POST /api/services/camera/{service}
│ └─ Any service? → POST /api/services/{domain}/{service}
│
├─ MODIFY STATE (NOT FOR DEVICE CONTROL)?
│ ├─ Create/update state? → POST /api/states/{entity_id}
│ ├─ Delete state? → DELETE /api/states/{entity_id}
│ └─ Fire custom event? → POST /api/events/{event_type}
│
└─ MANAGE SYSTEM?
├─ Validate config? → POST /api/config/core/check_config
├─ Reload config? → POST /api/services/homeassistant/reload_core_config
├─ Restart Home Assistant? → POST /api/services/homeassistant/restart
├─ Get components list? → GET /api/components
├─ Update entity metadata? → POST /api/services/homeassistant/update_entity
└─ Check error log? → GET /api/error_log
Phase 3: Execution & Validation
Before Calling API:
- Do you have correct entity_id? (domain.name format)
- Are you using the right HTTP method? (GET vs POST vs DELETE)
- Is your authentication token valid?
- For service calls, do you have the right parameters?
During Execution:
- Handle error responses appropriately (401, 404, 500, etc.)
- Retry on network errors with exponential backoff
- Monitor performance for polling operations
After Execution:
- Verify response matches expectation
- Check for error codes in response
- Cache results if applicable
Common Task Patterns
Query Current State
# Get one light's state
GET /api/states/light.kitchen
# Get temperature reading
GET /api/states/sensor.temperature
# Get all lights
GET /api/states
# Then filter: .[] | select(.entity_id | startswith("light."))
Load: resources/state-management.md then resources/core-concepts.md for HTTP details
Turn on/off Devices
# Turn on light with brightness
POST /api/services/light/turn_on
{"entity_id": "light.kitchen", "brightness": 200}
# Turn off all lights
POST /api/services/light/turn_off
{"entity_id": "all"}
# Toggle switch
POST /api/services/switch/toggle
{"entity_id": "switch.coffee_maker"}
Load: resources/service-reference.md + resources/entity-types.md for specific parameters
Query Multiple Entities
Option 1: Multiple API calls (simple, high bandwidth)
GET /api/states/light.kitchen
GET /api/states/light.living_room
GET /api/states/light.bedroom
Option 2: Get all and filter (one call, parse locally)
GET /api/states
# Filter in client: select by entity_id prefix
Option 3: Server-side template (most efficient)
POST /api/template
{"template": "{{ states.light | selectattr('state', 'eq', 'on') | list | length }}"}
Load: resources/templates.md for advanced queries
Batch Operations
# Bad: Multiple sequential API calls
POST /api/services/light/turn_on {"entity_id": "light.kitchen"}
POST /api/services/light/turn_on {"entity_id": "light.living_room"}
POST /api/services/light/turn_on {"entity_id": "light.bedroom"}
# Better: Array of entities in one call
POST /api/services/light/turn_on
{"entity_id": ["light.kitchen", "light.living_room", "light.bedroom"]}
# Best: Use Home Assistant script (for complex multi-step)
POST /api/services/script/turn_on
{"entity_id": "script.my_scene"}
Load: resources/examples.md for working code patterns
Entity Type Quick Reference
Read-Only (Sensors)
sensor.*- Numeric/text readingsbinary_sensor.*- On/off detectioncamera.*- Camera snapshots
Load: resources/entity-types.md for attributes
Controllable Entities
light.*- Lights (on/off, brightness, color)switch.*- Switches (on/off)climate.*- Thermostats (temperature, mode)cover.*- Blinds, doors (open/close, position)lock.*- Locks (lock/unlock)fan.*- Fans (on/off, speed, oscillate)media_player.*- Media devices (play/pause, volume)
Load: resources/entity-types.md then resources/service-reference.md
Meta Entities (Non-device)
automation.*- Automations (trigger, turn on/off)script.*- Scripts (turn on/off)scene.*- Scenes (activate)group.*- Entity groupsperson.*- Location trackingdevice_tracker.*- Device trackinginput_*- Input helpers
Status Entities
person.*- "home" or "not_home"device_tracker.*- Location statesun.sun- "above_horizon" or "below_horizon"weather.*- Weather conditions
Service Call Parameters
Most Common Services
| Domain | Service | Key Parameters |
|---|---|---|
| light | turn_on | entity_id, brightness, rgb_color, transition |
| light | turn_off | entity_id, transition |
| switch | turn_on | entity_id |
| switch | turn_off | entity_id |
| climate | set_temperature | entity_id, temperature, hvac_mode |
| climate | set_hvac_mode | entity_id, hvac_mode |
| cover | open_cover | entity_id |
| cover | set_cover_position | entity_id, position (0-100) |
| lock | lock | entity_id, code (optional) |
| lock | unlock | entity_id, code (optional) |
| fan | turn_on | entity_id, percentage, preset_mode |
| media_player | play_media | entity_id, media_content_id, media_content_type |
| notify | mobile_app_* | message, title, data |
| automation | trigger | entity_id |
| script | turn_on | entity_id |
| scene | turn_on | entity_id, transition |
Load: resources/service-reference.md for complete reference
Response Handling
Success (200)
{
"entity_id": "light.kitchen",
"state": "on",
"attributes": {...},
"last_changed": "...",
"last_updated": "...",
"context": {...}
}
Authorization Error (401)
{
"error": "Unauthorized",
"message": "Invalid authentication provided"
}
Solution: Check token, regenerate if needed
Not Found (404)
{
"error": "Entity not found",
"message": "No entity found for domain 'light' and name 'nonexistent'"
}
Solution: Verify entity_id exists, check spelling
Bad Request (400)
{
"error": "Invalid JSON",
"message": "..."
}
Solution: Validate JSON syntax, required fields
Server Error (500)
Solution: Check HA error log, restart if needed
Load: resources/core-concepts.md for detailed error handling
Python Example Workflow
import requests
class HomeAssistant:
def __init__(self, url, token):
self.url = url
self.headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
# State queries
def get_state(self, entity_id):
"""Load: state-management.md"""
return requests.get(f"{self.url}/api/states/{entity_id}",
headers=self.headers).json()
# Service calls
def turn_on_light(self, entity_id, brightness=None):
"""Load: service-reference.md + entity-types.md"""
data = {"entity_id": entity_id}
if brightness:
data["brightness"] = brightness
return requests.post(
f"{self.url}/api/services/light/turn_on",
headers=self.headers,
json=data
).json()
# Complex queries
def count_on_lights(self):
"""Load: templates.md"""
template = "{{ states.light | selectattr('state', 'eq', 'on') | list | length }}"
resp = requests.post(
f"{self.url}/api/template",
headers=self.headers,
json={"template": template}
)
return int(resp.json()['result'])
# Usage
ha = HomeAssistant("http://localhost:8123", "YOUR_TOKEN")
# Query state
kitchen = ha.get_state("light.kitchen")
print(f"Kitchen light: {kitchen['state']}")
# Control device
ha.turn_on_light("light.kitchen", brightness=200)
# Complex query
count = ha.count_on_lights()
print(f"{count} lights are on")
Load: resources/examples.md for complete working examples
Decision Matrix: Which Task?
| I want to... | Load Resource | Example |
|---|---|---|
| Understand how to authenticate | core-concepts.md | Getting access token |
| Query temperature or sensor value | state-management.md | GET /api/states/sensor.temp |
| Turn on a light | service-reference.md → entity-types.md | POST /api/services/light/turn_on |
| Find devices with low battery | templates.md | Server-side template query |
| Understand light color options | entity-types.md | Brightness, RGB, HS color |
| Count how many lights are on | templates.md | selectattr filter |
| Check if config is valid | system-config.md | POST /api/config/core/check_config |
| Write working Python code | examples.md | Complete client implementation |
| Handle errors properly | core-concepts.md → examples.md | Retry logic, error codes |
| Batch control multiple devices | service-reference.md → examples.md | Array of entity_ids |
Recommended Learning Path
New to Home Assistant API?
resources/core-concepts.md- Understand authentication and basicsresources/state-management.md- Learn to query stateresources/service-reference.md- Learn to control devicesresources/examples.md- See working code
Building an integration?
resources/core-concepts.md- Error handling, timeoutsresources/examples.md- Client setup, retry logicresources/service-reference.md- Available operationsresources/templates.md- Complex queries
Power user optimizations?
resources/templates.md- Server-side queriesresources/system-config.md- Discovery, cachingresources/examples.md- Performance patterns
Next Step: Identify your task above, load the appropriate resource file, and proceed with implementation.
FAQ
What does the home-assistant-api skill do?
Orchestrates access to the Home Assistant REST API for programmatic control of smart home devices. Routes requests to specialized resource files based on task type - authentication, state management, service calls, entity types, or advanced queries. Provides intelligent decision tables for selecting appropriate endpoints and managing integrations.
How do I install home-assistant-api?
Run npx skills add https://github.com/markpitt/claude-skills --skill home-assistant-api in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/home-assistant-api/ (personal) or .claude/skills/home-assistant-api/ (project).
Which AI agents can use home-assistant-api?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is home-assistant-api safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains home-assistant-api?
It is published by markpitt in markpitt/claude-skills. It has 52 recorded installs.
More from markpitt/claude-skills
blazor-expert
markpitt/claude-skills
Comprehensive Blazor development expertise covering Blazor Server, WebAssembly, and Hybrid apps. Use when building Blazor components, implementing state management, handling routing, JavaScript interop, forms and validation, authentication, or optimizing Blazor applications. Includes best practices, architecture patterns, and troubleshooting guidance.
avalonia
markpitt/claude-skills
Expert guidance for developing cross-platform desktop applications with Avalonia UI framework. Use when building, debugging, or optimizing Avalonia apps including MVVM architecture, XAML design, data binding, styling, theming, custom controls, and cross-platform deployment for Windows, macOS, Linux, iOS, Android, and WebAssembly.
microsoft-graph
markpitt/claude-skills
Orchestration hub for Microsoft Graph API across Microsoft 365 services. Use for Graph API integrations, querying Microsoft 365 data, and building applications that interact with Azure AD.
kiss-principle
markpitt/claude-skills
Apply the K.I.S.S principle (Keep It Simple, Stupid) to reduce complexity, improve maintainability, and solve problems elegantly. Use when designing systems, writing code, planning solutions, creating documentation, architecting features, or making decisions where simplicity drives quality and efficiency.
markdown-formatter
markpitt/claude-skills
Formats markdown files according to best practices and common style guidelines. Use when cleaning up markdown documentation, ensuring consistent formatting, or standardizing README files.
azure-devops
markpitt/claude-skills
Comprehensive skill for working with Azure DevOps REST API across all services including Boards (work items, queries, backlogs), Repos (Git, pull requests, commits), Pipelines (builds, releases, deployments), Test Plans, Artifacts, organizations, projects, security, extensions, and more. Use when implementing Azure DevOps integrations, automating DevOps workflows, or building applications that interact with Azure DevOps services.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.