-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel.go
100 lines (87 loc) · 2.05 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package miio
import (
"fmt"
)
type PropParam struct {
Did string `json:"did"`
Siid int `json:"siid"`
Piid int `json:"piid"`
Value any `json:"value,omitempty"`
}
func (p *PropParam) SetDid(did string) *PropParam {
if did == "" {
p.Did = fmt.Sprintf("%d-%d", p.Siid, p.Piid)
} else {
p.Did = did
}
return p
}
type PropParams []PropParam
type ActionParam struct {
Did string `json:"did"`
Siid int `json:"siid"`
Aiid int `json:"aiid"`
In []any `json:"in,omitempty"`
Out []any `json:"out,omitempty"`
}
func (a *ActionParam) SetDid(did string) *ActionParam {
if did == "" {
a.Did = fmt.Sprintf("%d-%d", a.Siid, a.Aiid)
} else {
a.Did = did
}
return a
}
type PropRet struct {
PropParam
Code int `json:"code"`
ExeTime int `json:"exe_time"`
}
type PropRets []PropRet
type PropParamsReq struct {
Params PropParams `json:"params"`
Method string `json:"method,omitempty"`
}
// type ActionRet struct {
// ActionParam
// Miid int `json:"miid"`
// Code int `json:"code"`
// ExeTime int `json:"exe_time"`
// WithLatency int `json:"withLatency"`
// }
// type ActionParamReq struct {
// Param ActionParam `json:"params"`
// }
type Ret struct {
ID int `json:"id"`
Error struct {
Code int `json:"code"`
Message string `json:"message"`
} `json:"error"`
Result any `json:"result"`
ExeTime int `json:"exe_time"`
}
type Info struct {
Life int `json:"life"`
Model string `json:"model"`
Token string `json:"token"`
Ipflag int `json:"ipflag"`
MiioVer string `json:"miio_ver"`
HwVer string `json:"hw_ver"`
Mmfree int `json:"mmfree"`
FwVer string `json:"fw_ver"`
Mac string `json:"mac"`
WifiFwVer string `json:"wifi_fw_ver"`
Ap struct {
Ssid string `json:"ssid"`
Bssid string `json:"bssid"`
Rssi int `json:"rssi"`
Primary int `json:"primary"`
} `json:"ap"`
Netif struct {
LocalIP string `json:"localIp"`
Mask string `json:"mask"`
Gw string `json:"gw"`
} `json:"netif"`
PartnerID string `json:"partner_id"`
}