chore: 修复 import 路径为 xiaomihome/miot,补充 README 项目文档

go.mod 模块名为 xiaomihome,将所有内部 import 从 "miot" 更新为
"xiaomihome/miot",涉及所有测试文件和示例文件。新增 README.md 项目
介绍文档(架构概览、模块说明、移植进度等)。新增 ARCH_PLAN.md 架构
设计文档。
This commit is contained in:
2026-06-28 23:21:18 +08:00
parent 3a44cb9e6a
commit 35efed7d15
21 changed files with 1264 additions and 81 deletions
+53 -53
View File
@@ -6,7 +6,7 @@ import (
"testing"
"time"
miot "miot"
miot "xiaomihome/miot"
)
// ============================================================================
@@ -16,24 +16,24 @@ import (
func TestDevice_NewAllFields(t *testing.T) {
// nil client is valid for testing basic field parsing
deviceInfo := map[string]interface{}{
"did": "device_001",
"name": "Test Light",
"model": "lumi.plug.v1",
"online": true,
"home_id": "home_123",
"home_name": "My Home",
"room_id": "room_456",
"room_name": "Living Room",
"group_id": "group_789",
"fw_version": "1.0.0",
"manufacturer": "Xiaomi",
"icon": "https://example.com/icon.png",
"token": "abc123token",
"local_ip": "192.168.1.100",
"connect_type": float64(2),
"rssi": float64(-65),
"ssid": "MyWiFi",
"bssid": "00:11:22:33:44:55",
"did": "device_001",
"name": "Test Light",
"model": "lumi.plug.v1",
"online": true,
"home_id": "home_123",
"home_name": "My Home",
"room_id": "room_456",
"room_name": "Living Room",
"group_id": "group_789",
"fw_version": "1.0.0",
"manufacturer": "Xiaomi",
"icon": "https://example.com/icon.png",
"token": "abc123token",
"local_ip": "192.168.1.100",
"connect_type": float64(2),
"rssi": float64(-65),
"ssid": "MyWiFi",
"bssid": "00:11:22:33:44:55",
}
dev := miot.NewMIoTDevice(nil, deviceInfo, nil)
@@ -377,23 +377,23 @@ func TestDevice_SubEventNoClient(t *testing.T) {
func TestDevice_ToDict(t *testing.T) {
dev := miot.NewMIoTDevice(nil, map[string]interface{}{
"did": "dev1",
"name": "Test Device",
"model": "test.model.v1",
"online": true,
"home_id": "h1",
"home_name": "Home",
"room_id": "r1",
"room_name": "Room",
"group_id": "g1",
"fw_version": "1.0",
"icon": "icon.png",
"token": "tok",
"local_ip": "127.0.0.1",
"did": "dev1",
"name": "Test Device",
"model": "test.model.v1",
"online": true,
"home_id": "h1",
"home_name": "Home",
"room_id": "r1",
"room_name": "Room",
"group_id": "g1",
"fw_version": "1.0",
"icon": "icon.png",
"token": "tok",
"local_ip": "127.0.0.1",
"connect_type": float64(1),
"rssi": float64(-50),
"ssid": "wifi",
"bssid": "aa:bb",
"rssi": float64(-50),
"ssid": "wifi",
"bssid": "aa:bb",
}, nil)
dict := dev.ToDict()
@@ -449,24 +449,24 @@ func TestDevice_FromDict(t *testing.T) {
func TestDevice_ToDictFromDictRoundtrip(t *testing.T) {
original := miot.NewMIoTDevice(nil, map[string]interface{}{
"did": "roundtrip",
"name": "Roundtrip",
"model": "m.v",
"online": true,
"manufacturer": "Mfr",
"fw_version": "2.0",
"icon": "i.png",
"home_id": "h",
"home_name": "hn",
"room_id": "r",
"room_name": "rn",
"group_id": "g",
"connect_type": float64(3),
"rssi": float64(-30),
"ssid": "s",
"bssid": "b",
"token": "t",
"local_ip": "10.0.0.1",
"did": "roundtrip",
"name": "Roundtrip",
"model": "m.v",
"online": true,
"manufacturer": "Mfr",
"fw_version": "2.0",
"icon": "i.png",
"home_id": "h",
"home_name": "hn",
"room_id": "r",
"room_name": "rn",
"group_id": "g",
"connect_type": float64(3),
"rssi": float64(-30),
"ssid": "s",
"bssid": "b",
"token": "t",
"local_ip": "10.0.0.1",
}, nil)
dict := original.ToDict()