SuperAPI AI 工具集

ha-debugging

测试与质量

查看项目

更新于 10-15 23:48

技能介绍

用途:帮助调试和排除 Home Assistant 集成(特别是 custom_components)的故障,适合遇到 error、debug、not working、unavailable、traceback、exception、日志报错等症状时使用。

主要能力:

  1. 开启调试日志:在 configuration.yaml 中为 custom_components.{domain} 与 homeassistant.config_entries 设置 debug 级别,并通过 Settings → System → Logs 或 tail -f config/home-assistant.log 查看。
  2. 按症状定位错误类别,例如集成无法加载、Config flow 无法加载、setup 出现 Unexpected exception、实体 unavailable、实体不出现、ConfigEntryNotReady、状态不更新等,并对应检查 init.py、manifest.json、config_flow.py、strings.json、coordinator.py、平台文件等。
  3. 常见修复:相对导入写法、manifest.json requirements、初始化 errors 字典、coordinator 正确抛出 UpdateFailed、实体 available 属性、PLATFORMS 列表与 async_forward_entry_setups、async_add_entities 调用、避免阻塞事件循环(用 await hass.async_add_executor_job)、检查继承顺序与 super().init() 调用、native_value 读取 coordinator 数据。
  4. 诊断命令:用 python3 -c 校验 manifest.json 与 strings.json 的 JSON、python3 -m py_compile 检查语法、ruff check 与 mypy 做检查、grep 日志确认是否加载。

使用方式:按工作流进行——重现问题、开启调试日志、查找第一个错误而非最后一个、隔离到具体文件与函数、施加针对性修复、重启 HA 验证、编写回归测试。日志查看方式随安装类型不同:Core/venv 可直接操作 config/home-assistant.log;HA OS/Supervised/Container 无该路径 shell 访问,需通过 Settings → System → Logs、ha core logs 或 docker logs homeassistant 查看。

适用场景:开发或维护 Home Assistant 自定义集成、排查实体不可用或状态不更新、调试配置流异常与导入错误。

限制:资料未提供该技能的具体安装方式、收费信息或兼容版本;文中命令示例为原始内容,需结合自身安装环境使用。