home-assistant by balloob/llm-skills
npx skills add https://github.com/balloob/llm-skills --skill home-assistant此技能帮助用户将 Home Assistant 集成到他们的项目中,无论是控制智能家居设备还是获取传感器数据和状态信息。该技能将指导用户完成连接设置、验证凭据,并提供适用于 Python 和 Node.js 的全面 API 参考文档。
当用户希望进行以下操作时,请使用此技能:
从用户处收集两条信息:
如果用户提供的 URL 包含路径部分(例如,http://homeassistant.local:8123/lovelace/dashboard),请通过移除主机和端口之后的所有内容来规范化它。基础 URL 应仅包含协议、主机和端口:
http://homeassistant.local:8123http://homeassistant.local:8123/lovelace/dashboard广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果用户不知道在哪里找到他们的长期访问令牌,请提供以下说明:
使用 curl 测试连接并获取 Home Assistant 配置信息。
curl -X GET \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
<URL>/api/config
示例:
curl -X GET \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
http://homeassistant.local:8123/api/config
成功输出:
{
"location_name": "Home",
"latitude": 37.7749,
"longitude": -122.4194,
"elevation": 0,
"unit_system": {
"length": "km",
"mass": "g",
"temperature": "°C",
"volume": "L"
},
"time_zone": "America/Los_Angeles",
"version": "2024.1.0",
"config_dir": "/config",
"allowlist_external_dirs": [],
"allowlist_external_urls": [],
"components": ["automation", "light", "switch", ...],
"config_source": "storage"
}
响应中的关键信息:
version:Home Assistant 版本(例如,"2024.1.0")location_name:Home Assistant 实例的名称time_zone:配置的时区components:已加载的组件/集成列表失败场景:
身份验证失败 (401):
{"message": "Invalid authentication"}
连接失败:
curl: (7) Failed to connect to homeassistant.local port 8123: Connection refused
如果身份验证失败,请验证:
一旦连接验证通过,根据用户的编程语言和需求,帮助他们实施集成。
重要提示:以下 WebSocket API 命令构成了用户与 Home Assistant 交互的核心方式。这些命令利用了自动化引擎,并通过使用原生的 Home Assistant 语法来保持脚本的简洁性。
这些命令需要 WebSocket API 连接,提供了与 Home Assistant 交互最强大、最灵活的方式:
使用场景:当您希望在特定条件发生时(状态变化、时间模式、webhook 等)收到通知
命令结构:
{
"type": "subscribe_trigger",
"trigger": {
"platform": "state",
"entity_id": "binary_sensor.motion_sensor",
"to": "on"
},
"variables": {
"custom_var": "value"
}
}
为何使用此命令:与其订阅所有状态变化并进行过滤,不如直接订阅您关心的触发器。这更高效,并且使用了 Home Assistant 的原生触发器语法。
使用场景:您需要检查某个条件是否满足,而无需在脚本中实现该逻辑
命令结构:
{
"type": "test_condition",
"condition": {
"condition": "numeric_state",
"entity_id": "sensor.temperature",
"above": 20
},
"variables": {
"custom_var": "value"
}
}
为何使用此命令:将条件逻辑卸载到 Home Assistant。您的脚本保持简单,同时利用 Home Assistant 强大的条件引擎。
使用场景:您需要执行一系列操作,包括 wait_for_trigger、延迟、服务调用等
命令结构:
{
"type": "execute_script",
"sequence": [
{
"service": "light.turn_on",
"target": {"entity_id": "light.living_room"}
},
{
"wait_for_trigger": [
{
"platform": "state",
"entity_id": "binary_sensor.motion",
"to": "off",
"for": {"minutes": 5}
}
]
},
{
"service": "light.turn_off",
"target": {"entity_id": "light.living_room"}
}
],
"variables": {
"custom_var": "value"
}
}
为何使用此命令:
wait_for_trigger 来等待事件包含响应数据的示例:
{
"type": "execute_script",
"sequence": [
{
"service": "weather.get_forecasts",
"target": {"entity_id": "weather.home"},
"response_variable": "weather_data"
},
{
"stop": "Done",
"response_variable": "weather_data"
}
]
}
要理解 Home Assistant 的信息架构,还需使用:
如果用户正在构建一个希望展示家庭当前状态的应用程序,请使用:
对于基于 Python 的项目,请参考 Python API 参考:
references/python_api.md对于基于 Node.js 的项目,请参考 Node.js API 参考:
references/node_api.mdhome-assistant-js-websocket 库的 WebSocket API 示例如果用户希望在不连接到真实的 Home Assistant 实例的情况下测试他们的代码,可以使用 empty-hass,这是一个 CLI 工具,可以启动一个带有预配置身份验证的空 Home Assistant 实例。
使用 uvx 运行 empty-hass(需要已安装 uv 的 Python):
uvx --from git+https://github.com/balloob/empty-hass empty-hass
这将在 http://localhost:8123 上启动一个 Home Assistant 实例,具有以下特点:
使用 --help 运行以查看可用选项和登录凭据:
uvx --from git+https://github.com/balloob/empty-hass empty-hass --help
这对于以下情况很有用:
读取传感器状态并在自定义仪表板或监控应用程序中显示它们。
订阅实体状态变化,并根据条件触发自定义操作。
从外部事件(webhook、计划任务、用户操作)调用 Home Assistant 服务。
从 Home Assistant 检索历史数据用于分析或备份目的。
每周安装数
89
仓库
GitHub 星标数
5
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode66
codex59
gemini-cli57
openclaw52
github-copilot50
cursor49
This skill helps users integrate Home Assistant into their projects, whether to control smart home devices or to ingest sensor data and state information. The skill guides users through connection setup, validates credentials, and provides comprehensive API reference documentation for both Python and Node.js.
Use this skill when users want to:
Collect two pieces of information from the user:
If the user provides a URL with a path component (e.g., http://homeassistant.local:8123/lovelace/dashboard), normalize it by removing everything after the host and port. The base URL should only include the scheme, host, and port:
http://homeassistant.local:8123http://homeassistant.local:8123/lovelace/dashboardIf users don't know where to find their Long-Lived Access Token, provide these instructions:
Use curl to test the connection and retrieve Home Assistant configuration information.
curl -X GET \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
<URL>/api/config
Example:
curl -X GET \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
http://homeassistant.local:8123/api/config
Success output:
{
"location_name": "Home",
"latitude": 37.7749,
"longitude": -122.4194,
"elevation": 0,
"unit_system": {
"length": "km",
"mass": "g",
"temperature": "°C",
"volume": "L"
},
"time_zone": "America/Los_Angeles",
"version": "2024.1.0",
"config_dir": "/config",
"allowlist_external_dirs": [],
"allowlist_external_urls": [],
"components": ["automation", "light", "switch", ...],
"config_source": "storage"
}
Key information from the response:
version: Home Assistant version (e.g., "2024.1.0")location_name: Name of the Home Assistant instancetime_zone: Configured time zonecomponents: List of loaded components/integrationsFailure scenarios:
Authentication failure (401):
{"message": "Invalid authentication"}
Connection failure:
curl: (7) Failed to connect to homeassistant.local port 8123: Connection refused
If authentication fails, verify:
Once the connection is validated, help the user implement their integration based on their programming language and requirements.
IMPORTANT : The following WebSocket API commands form the core of how users should interact with Home Assistant. These leverage the automation engine and keep scripts minimal by using native Home Assistant syntax.
These commands require WebSocket API connection and provide the most powerful and flexible way to interact with Home Assistant:
Use this when : You want to be notified when specific conditions occur (state changes, time patterns, webhooks, etc.)
Command structure :
{
"type": "subscribe_trigger",
"trigger": {
"platform": "state",
"entity_id": "binary_sensor.motion_sensor",
"to": "on"
},
"variables": {
"custom_var": "value"
}
}
Why use this : Instead of subscribing to all state changes and filtering, subscribe directly to the triggers you care about. This is more efficient and uses Home Assistant's native trigger syntax.
Use this when : You need to check if a condition is met without implementing the logic in your script
Command structure :
{
"type": "test_condition",
"condition": {
"condition": "numeric_state",
"entity_id": "sensor.temperature",
"above": 20
},
"variables": {
"custom_var": "value"
}
}
Why use this : Offload condition logic to Home Assistant. Your script stays simple while using Home Assistant's powerful condition engine.
Use this when : You need to execute a sequence of actions, including wait_for_trigger, delays, service calls, and more
Command structure :
{
"type": "execute_script",
"sequence": [
{
"service": "light.turn_on",
"target": {"entity_id": "light.living_room"}
},
{
"wait_for_trigger": [
{
"platform": "state",
"entity_id": "binary_sensor.motion",
"to": "off",
"for": {"minutes": 5}
}
]
},
{
"service": "light.turn_off",
"target": {"entity_id": "light.living_room"}
}
],
"variables": {
"custom_var": "value"
}
}
Why use this :
wait_for_trigger to wait for eventsExample with response data :
{
"type": "execute_script",
"sequence": [
{
"service": "weather.get_forecasts",
"target": {"entity_id": "weather.home"},
"response_variable": "weather_data"
},
{
"stop": "Done",
"response_variable": "weather_data"
}
]
}
To understand Home Assistant's information architecture, also use:
If the user is building an application that wants to represent the current state of the home, use:
For Python-based projects, refer to the Python API reference:
references/python_api.mdFor Node.js-based projects, refer to the Node.js API reference:
references/node_api.mdhome-assistant-js-websocket libraryIf users want to test their code without connecting to a real Home Assistant instance, they can use empty-hass , a CLI tool that starts an empty Home Assistant instance with pre-configured authentication.
Run empty-hass using uvx (requires Python with uv installed):
uvx --from git+https://github.com/balloob/empty-hass empty-hass
This will start a Home Assistant instance on http://localhost:8123 with:
Run with --help to see available options and login credentials:
uvx --from git+https://github.com/balloob/empty-hass empty-hass --help
This is useful for:
Read sensor states and display them in a custom dashboard or monitoring application.
Subscribe to entity state changes and trigger custom actions based on conditions.
Call Home Assistant services from external events (webhooks, scheduled jobs, user actions).
Retrieve historical data from Home Assistant for analysis or backup purposes.
Weekly Installs
89
Repository
GitHub Stars
5
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
opencode66
codex59
gemini-cli57
openclaw52
github-copilot50
cursor49
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
46,900 周安装