ha-core
БесплатноБез исполняемых скриптовНе проверенCore Home Assistant API integration patterns, authentication, and entity management.
от TheLobbi★ 22 звезды на GitHubОб этом скилле
Home Assistant Core Skill
Core Home Assistant API integration patterns, authentication, and entity management.
Activation Triggers
Activate this skill when working with:
- Home Assistant REST API
- WebSocket API connections
- Entity state management
- Service calls
- Event bus subscriptions
Authentication
Long-Lived Access Token
import httpx
class HAClient:
def __init__(self, url: str, token: str):
self.url = url.rstrip('/')
self.headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
async def get_states(self) -> list:
async with httpx.AsyncClient() as client:
response = await client.get(
f"{self.url}/api/states",
headers=self.headers
)
response.raise_for_status()
return response.json()
async def get_state(self, entity_id: str) -> dict:
async with httpx.AsyncClient() as client:
response = await client.get(
f"{self.url}/api/states/{entity_id}",
headers=self.headers
)
response.raise_for_status()
return response.json()
async def call_service(
self,
domain: str,
service: str,
data: dict = None,
target: dict = None
) -> dict:
payload = {}
if data:
payload.update(data)
if target:
payload["target"] = target
async with httpx.AsyncClient() as client:
response = await client.post(
f"{self.url}/api/services/{domain}/{service}",
headers=self.headers,
json=payload
)
response.raise_for_status()
return response.json()
TypeScript Client
interface HAState {
entity_id: string;
state: string;
attributes: Record<string, any>;
last_changed: string;
last_updated: string;
}
class HomeAssistantClient {
private url: string;
private token: string;
constructor(url: string, token: string) {
this.url = url.replace(/\/$/, '');
this.token = token;
}
private get headers(): HeadersInit {
return {
'Authorization': `Bearer ${this.token}`,
'Content-Type': 'application/json'
};
}
async getStates(): Promise<HAState[]> {
const response = await fetch(`${this.url}/api/states`, {
headers: this.headers
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
async callService(
domain: string,
service: string,
data?: Record<string, any>,
target?: { entity_id?: string | string[] }
): Promise<any> {
const response = await fetch(
`${this.url}/api/services/${domain}/${service}`,
{
method: 'POST',
headers: this.headers,
body: JSON.stringify({ ...data, target })
}
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
}
WebSocket API
Real-Time State Updates
import asyncio
import json
import websockets
class HAWebSocket:
def __init__(self, url: str, token: str):
self.url = url.replace('http', 'ws') + '/api/websocket'
self.token = token
self.message_id = 0
self.ws = None
async def connect(self):
self.ws = await websockets.connect(self.url)
# Wait for auth_required
await self.ws.recv()
# Send auth
await self.ws.send(json.dumps({
"type": "auth",
"access_token": self.token
}))
# Wait for auth_ok
result = json.loads(await self.ws.recv())
if result["type"] != "auth_ok":
raise Exception("Authentication failed")
async def subscribe_events(self, event_type: str = None):
self.message_id += 1
msg = {
"id": self.message_id,
"type": "subscribe_events"
}
if event_type:
msg["event_type"] = event_type
await self.ws.send(json.dumps(msg))
return self.message_id
async def subscribe_state_changes(self, entity_id: str = None):
self.message_id += 1
msg = {
"id": self.message_id,
"type": "subscribe_trigger",
"trigger": {
"platform": "state"
}
}
if entity_id:
msg["trigger"]["entity_id"] = entity_id
await self.ws.send(json.dumps(msg))
return self.message_id
async def listen(self):
async for message in self.ws:
yield json.loads(message)
# Usage
async def monitor_states():
ws = HAWebSocket("http://homeassistant.local:8123", "token")
await ws.connect()
await ws.subscribe_events("state_changed")
async for event in ws.listen():
if event.get("type") == "event":
data = event["event"]["data"]
Установить ha-core в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ha-core?
Core Home Assistant API integration patterns, authentication, and entity management.
Как установить скилл ha-core?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ha-core запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic