From 9637c7f39db96a2dda1b0a1164b74d359b49ab23 Mon Sep 17 00:00:00 2001 From: impressionyang Date: Wed, 15 Apr 2026 19:10:28 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=B0=E5=BD=95=20-=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=94=99=E8=AF=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- 问题修复记录.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/问题修复记录.md b/问题修复记录.md index 2427624..8492d69 100644 --- a/问题修复记录.md +++ b/问题修复记录.md @@ -8,13 +8,22 @@ ### 根本原因 1. **类型注解错误**:`config_flow.py` 使用了小写 `any` 而非 `Any` 2. **依赖包不存在**:`manifest.json` 中引用了不存在的 `bleak-mesh>=0.2.0` +3. **导入错误**:`coordinator.py` 从错误的模块导入 `MeshMessageEvent` 和 `ProvDeviceEvent` ### 错误日志 + +#### 错误 1: 依赖包不存在 ``` homeassistant.requirements.RequirementsNotFound: Requirements for sigmesh_gateway not found: ['bleak-mesh>=0.2.0']. ``` +#### 错误 2: 导入错误 +``` +Error occurred loading flow for integration sigmesh_gateway: +cannot import name 'MeshMessageEvent' from 'custom_components.sigmesh_gateway.protocol_parser' +``` + ### 解决方案 #### 修复 1: config_flow.py 类型注解 @@ -23,9 +32,6 @@ Requirements for sigmesh_gateway not found: ['bleak-mesh>=0.2.0']. - async def async_step_user(self, user_input: dict[str, any] | None = None) -> FlowResult: + async def async_step_user(self, user_input: dict[str, Any] | None = None) -> FlowResult: - -- async def async_step_init(self, user_input: dict[str, any] | None = None) -> FlowResult: -+ async def async_step_init(self, user_input: dict[str, Any] | None = None) -> FlowResult: ``` #### 修复 2: manifest.json 依赖 @@ -34,11 +40,29 @@ Requirements for sigmesh_gateway not found: ['bleak-mesh>=0.2.0']. + "requirements": ["pyserial-asyncio-fast>=0.6"], ``` +#### 修复 3: coordinator.py 导入 +```diff +from .protocol_parser import ( + DeviceManager, + DeviceState, +- MeshMessageEvent, + ParsedMeshMessage, +- ProvDeviceEvent, + ProtocolParser, +) ++ from .serial_reader import ( ++ MeshMessageEvent, ++ ProvDeviceEvent, ++ SerialReader, ++ ) +``` + ### 提交记录 | Commit | 说明 | |--------|------| -| 66b86e3 | fix: 修复 config_flow.py 类型注解错误 | +| 472fec4 | fix: 修复 coordinator.py 导入错误 | | e905410 | fix: 修复 manifest.json 依赖错误 | +| 66b86e3 | fix: 修复 config_flow.py 类型注解错误 | ### 部署步骤 ```bash