docs: 更新问题修复记录 - 添加第二次修复

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
impressionyang 2026-04-16 09:48:31 +08:00
parent 311cfbbe7e
commit e88ddae6ca

View File

@ -1,6 +1,75 @@
# 问题修复记录 # 问题修复记录
## 2026-04-16: 修复平台加载和 OptionsFlow 错误 ## 2026-04-16: 修复平台加载和 OptionsFlow 错误(第二次修复)
### 问题描述
平台文件设置时出现 `'NoneType' object has no attribute 'values'` 错误
### 错误日志
#### 错误 1: 平台文件访问 None 数据
```
AttributeError: 'NoneType' object has no attribute 'values'
File: sensor.py, line 40
File: binary_sensor.py, line 37
File: switch.py, line 34
File: light.py, line 40
File: device_tracker.py, line 34
```
**原因**: `coordinator.data` 在初始化时为 `None`
#### 错误 2: OptionsFlow 初始化错误
```
TypeError: SigMeshGatewayOptionsFlow() takes no arguments
File: config_flow.py, line 74
```
**原因**: `async_get_options_flow` 是静态方法,传递了 `config_entry` 参数,但 `__init__` 不接受参数
### 解决方案
#### 修复 1: 平台文件添加 None 检查
```python
async def async_setup_entry(...):
if coordinator.data is None:
_LOGGER.debug("协调器数据为空,等待设备数据")
return
for device in coordinator.data.values():
...
```
#### 修复 2: 修复 async_get_options_flow
```python
@callback
def async_get_options_flow(self) -> SigMeshGatewayOptionsFlow:
"""获取选项流程."""
return SigMeshGatewayOptionsFlow()
```
#### 修复 3: OptionsFlow 添加 __init__
```python
class SigMeshGatewayOptionsFlow(config_entries.OptionsFlow):
def __init__(self) -> None:
"""初始化选项流程."""
self._errors: dict[str, str] = {}
```
### 提交记录
| Commit | 说明 |
|--------|------|
| 311cfbb | fix: 修复平台文件和 OptionsFlow 错误 |
### 部署步骤
```bash
cp -r custom_components/sigmesh_gateway ~/.homeassistant/custom_components/
ha core restart
```
---
## 2026-04-16: 修复平台加载和 OptionsFlow 错误(第一次修复)
### 问题描述 ### 问题描述
配置集成时出现错误,无法加载平台实体 配置集成时出现错误,无法加载平台实体