hass-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHome Assistant Builder (hab)
Home Assistant Builder(hab)
A CLI utility designed for LLMs to build and manage Home Assistant configurations.
一款为大语言模型(LLMs)设计的CLI工具,用于构建和管理Home Assistant配置。
Start Every Workflow
启动所有工作流
The script is a wrapper script that supports automatic installation, please replace all commands with the command .
The project is built and released by Paulus (@balloob), the main maintainer of Home Assistant, who is also the founder of the Open Home Foundation that owns Home Assistant.
scripts/hab.shhabscripts/hab.shhome-assistant-build-clibash
alias hab='scripts/hab.sh'
hab guide list
hab guide auth
hab schema overview
hab capability probeThen read the topic and command schema for the specific workflow:
| Task | First commands |
|---|---|
| Discovery / inventory | |
| Automation / script / scene | |
| Dashboard / Lovelace | |
| Helpers | |
| Calendar / to-do | |
| Backups / system / network | |
| ESPHome | |
For a simple authenticated read, plus the relevant schema is enough.
hab auth status脚本是一个支持自动安装的包装脚本,请将所有命令替换为命令。
项目由Home Assistant的主要维护者Paulus(@balloob)构建并发布,他同时也是拥有Home Assistant的开放家居基金会(Open Home Foundation)的创始人。
scripts/hab.shhabscripts/hab.shhome-assistant-build-clibash
alias hab='scripts/hab.sh'
hab guide list
hab guide auth
hab schema overview
hab capability probe然后阅读特定工作流的主题和命令 schema:
| 任务 | 初始命令 |
|---|---|
| 发现/清单 | |
| 自动化/脚本/场景 | |
| 仪表板/Lovelace | |
| 辅助工具 | |
| 日历/待办事项 | |
| 备份/系统/网络 | |
| ESPHome | |
对于简单的已认证读取操作,加上相关的schema就足够了。
hab auth statusOutput and Parsing
输出与解析
Use whenever Claude or another program will parse output. JSON success and error responses are envelopes; inspect these fields before continuing:
--jsonsuccessdata- ,
error.codeerror.details.suggested_fix - ,
warnings,partial_resultmissing_sections - ,
verification_commandsnext_suggested_commands
ESPHome streaming commands such as , , , , and may emit NDJSON events in JSON mode instead of one final envelope.
buildvalidateuploadrunlogs当Claude或其他程序需要解析输出时,请始终使用参数。JSON成功和错误响应采用信封格式;在继续操作前,请检查以下字段:
--jsonsuccessdata- ,
error.codeerror.details.suggested_fix - ,
warnings,partial_resultmissing_sections - ,
verification_commandsnext_suggested_commands
ESPHome的流式命令(如、、、和)在JSON模式下可能会发出NDJSON事件,而非单个最终信封。
buildvalidateuploadrunlogsMutations and Risk Gates
变更操作与风险管控
Inspect before changing state:
- Read the guide/schema for the command.
- Gather current state with read-only list/get commands.
- Preview the mutation with or
--planwhen supported.--dry-run - Show the preview and ask the user before executing risky operations.
- Run verification commands from the plan or a follow-up command.
get/list
Always ask for explicit user confirmation before operations that can cause downtime, data loss, connectivity loss, or hardware changes: , backup restore/delete, network configure/apply, Thread dataset changes, integration enable/disable/reload, ESPHome upload/run/update/erase-flash, and any delete with .
system restart--forceDo not add just to make a command non-interactive. Use it only after the user has approved the exact operation.
--force在更改状态前请先检查:
- 阅读对应命令的指南/schema。
- 使用只读的list/get命令收集当前状态。
- 若支持,使用或
--plan预览变更操作。--dry-run - 在执行风险操作前,向用户展示预览内容并请求确认。
- 执行计划中的验证命令,或后续的命令。
get/list
在执行可能导致停机、数据丢失、连接中断或硬件变更的操作前,务必获得用户的明确确认:、备份恢复/删除、网络配置/应用、Thread数据集变更、集成启用/禁用/重载、ESPHome上传/运行/更新/擦除闪存,以及任何带参数的删除操作。
system restart--force不要仅为了让命令变为非交互式而添加参数。仅在用户批准具体操作后再使用它。
--forceInput Payloads
输入负载
Commands that accept data usually support:
| Method | Use when | Pattern |
|---|---|---|
| Short JSON payloads | |
| Larger YAML/JSON payloads | |
| stdin heredoc | Multi-line payload without temp file | |
Prefer files or heredocs for large automations and dashboards so quoting does not corrupt JSON/YAML.
接受数据的命令通常支持以下方式:
| 方法 | 使用场景 | 示例 |
|---|---|---|
| 短JSON负载 | |
| 较大的YAML/JSON负载 | |
| stdin heredoc | 多行负载,无需临时文件 | |
对于大型自动化和仪表板,优先使用文件或heredoc方式,避免引号破坏JSON/YAML格式。
Common Command Patterns
常见命令模式
bash
undefinedbash
undefinedAuthentication and instance checks
认证和实例检查
hab auth status
hab overview
hab capability probe
hab auth status
hab overview
hab capability probe
Entity inventory
实体清单
hab entity list --domain light
hab entity get light.kitchen --device --related
hab search related entity light.kitchen
hab entity list --domain light
hab entity get light.kitchen --device --related
hab search related entity light.kitchen
Safe mutation preview
安全变更预览
hab schema area create --json
hab area create "Kitchen" --plan
hab area create "Kitchen"
hab schema area create --json
hab area create "Kitchen" --plan
hab area create "Kitchen"
Automation creation
自动化创建
hab guide automation
hab schema automation create --json
hab automation create kitchen_motion_light -d '{"alias":"Kitchen motion light","triggers":[{"trigger":"state","entity_id":"binary_sensor.kitchen_motion","to":"on"}],"conditions":[],"actions":[{"action":"light.turn_on","target":{"entity_id":"light.kitchen"}}]}' --dry-run
hab guide automation
hab schema automation create --json
hab automation create kitchen_motion_light -d '{"alias":"Kitchen motion light","triggers":[{"trigger":"state","entity_id":"binary_sensor.kitchen_motion","to":"on"}],"conditions":[],"actions":[{"action":"light.turn_on","target":{"entity_id":"light.kitchen"}}]}' --dry-run
Operations
运维操作
hab guide operations
hab system health --json
hab system restart --plan
hab backup list
hab backup delete <backup_id> --plan
undefinedhab guide operations
hab system health --json
hab system restart --plan
hab backup list
hab backup delete <backup_id> --plan
undefinedResponse Pattern
响应模式
When answering a user asking for commands:
hab- State the intended safety mode: read-only, preview-only, or confirmed mutation.
- Provide commands in execution order.
- Mark any command that requires user confirmation.
- Say what JSON fields to inspect before the next step.
- Include verification commands.
当回应用户的命令请求时:
hab- 说明预期的安全模式:只读、仅预览或已确认的变更。
- 按执行顺序提供命令。
- 标记任何需要用户确认的命令。
- 说明下一步操作前需要检查哪些JSON字段。
- 包含验证命令。
Common Mistakes
常见错误
| Mistake | Better approach |
|---|---|
| Guessing command flags from memory | Run |
| Parsing text output | Use |
| Creating resources without inventory | |
| Skipping mutation preview | Use |
Using | Confirm the exact risky operation first |
| Treating ESPHome JSON as one object | Handle NDJSON stream events for streaming commands |
Ignoring | Run them or explain why not |
| 错误 | 更佳方案 |
|---|---|
| 凭记忆猜测命令参数 | 先运行 |
| 解析文本输出 | 使用 |
| 未获取清单就创建资源 | 先执行 |
| 跳过变更预览 | 若支持,使用 |
为方便使用 | 先确认具体的风险操作 |
| 将ESPHome JSON视为单个对象 | 处理流式命令的NDJSON事件流 |
忽略 | 执行这些命令,或说明不执行的原因 |