Files
4566704 3a44cb9e6a feat: 初始化小米 IoT (MIoT) 智能家居 Go 库
- 实现 MIoT 客户端核心功能(MQTT 连接、设备管理、属性读写)
- 支持云端 API 调用与局域网设备发现(mDNS)
- 集成国际化(i18n)多语言支持
- 添加 MIoT 设备规约解析器(spec_parser)
- 包含单元测试与使用示例
2026-06-28 22:05:49 +08:00

105 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 第二轮移植审查 — 方法级对齐度分析
> 审查时间:2026-06-28
> 方法:逐文件对比 Python 和 Go 版本的类、方法、属性
## 总体评估
| 类别 | 数量 | 说明 |
|------|------|------|
| 完全对齐 | 10/14 | 核心协议层(MIPS/MQTT/LAN/HTTP/storage/mdns/network/i18n)|
| 部分缺失 | 3/14 | miot_client/miot_cloud/spec_parser 有少量缺失 |
| HA 专属 | — | entity 类、spec_transform 等属 HomeAssistant 层,移除此 Go 版本无需移植 |
| 资源文件 | 2 处 | lan/profile_models.yaml、specs/ 目录未复制 |
---
## 需要修复的缺失项(按优先级)
### 🔴 High — 核心功能缺失
| # | 文件 | 缺失项 | 子文档 |
|---|------|--------|--------|
| H1 | `spec_parser.go` | MIoTSpecProperty.eval_expr / value_format / value_precision | [R2-01-spec-properties.md](./migration/R2-01-spec-properties.md) |
| H2 | `spec_parser.go` | MIoTSpecValueList.names/values/descriptions/get_value_by_description/get_description_by_value | [R2-02-spec-valuelist.md](./migration/R2-02-spec-valuelist.md) |
| H3 | `spec_parser.go` | MIoTSpecProperty.writable/readable/notifiable 访问器 | [R2-03-spec-accessors.md](./migration/R2-03-spec-accessors.md) |
| H4 | `miot_client*.go` | sub_device_state / unsub_device_state | [R2-04-client-device-state.md](./migration/R2-04-client-device-state.md) |
| H5 | `miot_cloud.go` | MIoTOauthClient.set_redirect_url | [R2-05-cloud-oauth-redirect.md](./migration/R2-05-cloud-oauth-redirect.md) |
### 🟡 Medium — 配置/辅助功能缺失
| # | 文件 | 缺失项 | 子文档 |
|---|------|--------|--------|
| M1 | `miot_client.go` | 配置属性:action_debug / display_binary_text / display_binary_bool / cover_dead_zone_width / display_devices_changed_notify / persistent_notify | [R2-06-client-config.md](./migration/R2-06-client-config.md) |
| M2 | `miot_client*.go` | __request_refresh_auth_info / __request_refresh_user_cert | [R2-07-client-auth-refresh.md](./migration/R2-07-client-auth-refresh.md) |
| M3 | `miot_client*.go` | __show_*_notify 通知方法(3个) | [R2-08-client-notify.md](./migration/R2-08-client-notify.md) |
| M4 | `miot_cloud.go` | get_prop_async(did,siid,piid) 单属性获取 | [R2-09-cloud-single-prop.md](./migration/R2-09-cloud-single-prop.md) |
| M5 | `miot_storage.go` | MIoTCert.gen_user_csr | [R2-10-storage-csr.md](./migration/R2-10-storage-csr.md) |
| M6 | `miot_matcher.go` | iter_all_nodes / get(topic) | [R2-11-matcher-methods.md](./migration/R2-11-matcher-methods.md) |
| M7 | `const.go` | CtrlMode.load() 字符串解析工厂 | [R2-12-ctrlmode-load.md](./migration/R2-12-ctrlmode-load.md) |
### 🟢 Low — 资源文件
| # | 缺失内容 | 子文档 |
|---|---------|--------|
| L1 | `lan/profile_models.yaml` — LAN 设备 profile 映射 | [R2-13-resources-lan.md](./migration/R2-13-resources-lan.md) |
| L2 | `specs/` 目录(6个文件)— SPEC 扩展/过滤/多语言 | [R2-14-resources-specs.md](./migration/R2-14-resources-specs.md) |
---
## 无需移植的项(说明)
| Python 内容 | 原因 |
|------------|------|
| `MIoTServiceEntity` 等 4 个 entity 类 | HA 专属,Go 是纯库 |
| `MIoTDevice.parse_miot_*_entity` 系列 | HA 专属 entity 解析 |
| `spec_transform / unit_convert / icon_convert` | HA 专属展示转换 |
| `gen_device_entity_id` 系列 | HA 专属 entity ID |
| `_SpecBoolTranslation / _SpecFilter / _SpecAdd / _SpecModify` | HA 专属 spec 配置 |
| `MIoTHttp` 静态工具类 | Go 中 net/http 直接调用 |
| `_MipsClient` 的 log_debug/log_info/log_error | Go 标准日志即可 |
| `__get_prop_handler` 批量聚合 | Go 已用同步方式替代 |
---
## 任务表(共 14 项)
| # | 文件 | 类别 | 优先级 |
|---|------|------|--------|
| H1 | spec_parser.go | eval_expr/value_format/value_precision | 🔴 |
| H2 | spec_parser.go | ValueList 查询方法 | 🔴 |
| H3 | spec_parser.go | 属性访问器 | 🔴 |
| H4 | miot_client*.go | 设备状态订阅 | 🔴 |
| H5 | miot_cloud.go | OAuth redirect_url setter | 🔴 |
| M1 | miot_client.go | 配置属性 | 🟡 |
| M2 | miot_client*.go | auth/cert 刷新 | 🟡 |
| M3 | miot_client*.go | 通知方法 | 🟡 |
| M4 | miot_cloud.go | 单属性获取 | 🟡 |
| M5 | miot_storage.go | CSR 生成 | 🟡 |
| M6 | miot_matcher.go | 匹配器方法 | 🟡 |
| M7 | const.go | CtrlMode.load | 🟡 |
| L1 | - | 复制 lan/profile_models.yaml | 🟢 |
| L2 | - | 复制 specs/ 目录 | 🟢 |
---
## 子文档索引
```
go-miot/migration/
├── R2-01-spec-properties.md # eval_expr / value_format / value_precision
├── R2-02-spec-valuelist.md # names/values/descriptions/get_value_by/get_description_by
├── R2-03-spec-accessors.md # writable/readable/notifiable
├── R2-04-client-device-state.md # sub_device_state / unsub_device_state
├── R2-05-cloud-oauth-redirect.md # set_redirect_url
├── R2-06-client-config.md # 配置属性
├── R2-07-client-auth-refresh.md # auth/cert 刷新
├── R2-08-client-notify.md # 通知方法
├── R2-09-cloud-single-prop.md # 单属性获取
├── R2-10-storage-csr.md # CSR 生成
├── R2-11-matcher-methods.md # 匹配器方法
├── R2-12-ctrlmode-load.md # CtrlMode.load
├── R2-13-resources-lan.md # profile_models.yaml
└── R2-14-resources-specs.md # specs/ 目录
```