-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonStructs.go
225 lines (206 loc) · 6.79 KB
/
jsonStructs.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package main
import (
"fmt"
"os"
"strconv"
"text/tabwriter"
"time"
)
// used as a response when querying the device status at https://accsmart.panasonic.com/device/now/<deviceID>
type DeviceStatusFull struct {
DryTempMin int `json:"dryTempMin"`
ModeAvlList struct {
AutoMode int `json:"autoMode"`
FanMode int `json:"fanMode"`
} `json:"modeAvlList"`
AirSwingLR bool `json:"airSwingLR"`
Nanoe bool `json:"nanoe"`
AutoMode bool `json:"autoMode"`
AutoSwingUD bool `json:"autoSwingUD"`
EcoNavi bool `json:"ecoNavi"`
HeatTempMax int `json:"heatTempMax"`
TemperatureUnit int `json:"temperatureUnit"`
IAutoX bool `json:"iAutoX"`
CoolTempMin int `json:"coolTempMin"`
AutoTempMin int `json:"autoTempMin"`
QuietMode bool `json:"quietMode"`
PowerfulMode bool `json:"powerfulMode"`
Timestamp int64 `json:"timestamp"`
FanMode bool `json:"fanMode"`
CoolMode bool `json:"coolMode"`
SummerHouse int `json:"summerHouse"`
CoolTempMax int `json:"coolTempMax"`
Permission int `json:"permission"`
DryMode bool `json:"dryMode"`
HeatMode bool `json:"heatMode"`
FanSpeedMode int `json:"fanSpeedMode"`
DryTempMax int `json:"dryTempMax"`
AutoTempMax int `json:"autoTempMax"`
FanDirectionMode int `json:"fanDirectionMode"`
EcoFunction int `json:"ecoFunction"`
HeatTempMin int `json:"heatTempMin"`
PairedFlg bool `json:"pairedFlg"`
Parameters DeviceParamList `json:"parameters"`
}
type DeviceParamList struct {
EcoFunctionData int `json:"ecoFunctionData"`
AirSwingLR int `json:"airSwingLR"`
Nanoe int `json:"nanoe"`
EcoNavi int `json:"ecoNavi"`
EcoMode int `json:"ecoMode"`
OperationMode int `json:"operationMode"`
FanAutoMode int `json:"fanAutoMode"`
TemperatureSet float64 `json:"temperatureSet"`
FanSpeed int `json:"fanSpeed"`
IAuto int `json:"iAuto"`
AirQuality int `json:"airQuality"`
InsideTemperature int `json:"insideTemperature"`
OutTemperature int `json:"outTemperature"`
Operate int `json:"operate"`
AirDirection int `json:"airDirection"`
ActualNanoe int `json:"actualNanoe"`
AirSwingUD int `json:"airSwingUD"`
}
// used as a response when listing devices at https://accsmart.panasonic.com/device/group
type DeviceGroupList struct {
IaqStatus struct {
StatusCode int `json:"statusCode"`
} `json:"iaqStatus"`
UIFlg bool `json:"uiFlg"`
GroupCount int `json:"groupCount"`
GroupList []struct {
GroupID int `json:"groupId"`
GroupName string `json:"groupName"`
DeviceList []struct {
DeviceGUID string `json:"deviceGuid"`
DeviceType string `json:"deviceType"`
DeviceName string `json:"deviceName"`
Permission int `json:"permission"`
DeviceModuleNumber string `json:"deviceModuleNumber"`
DeviceHashGUID string `json:"deviceHashGuid"`
SummerHouse int `json:"summerHouse"`
IAutoX bool `json:"iAutoX"`
Nanoe bool `json:"nanoe"`
AutoMode bool `json:"autoMode"`
HeatMode bool `json:"heatMode"`
FanMode bool `json:"fanMode"`
DryMode bool `json:"dryMode"`
CoolMode bool `json:"coolMode"`
EcoNavi bool `json:"ecoNavi"`
PowerfulMode bool `json:"powerfulMode"`
QuietMode bool `json:"quietMode"`
AirSwingLR bool `json:"airSwingLR"`
AutoSwingUD bool `json:"autoSwingUD"`
EcoFunction int `json:"ecoFunction"`
TemperatureUnit int `json:"temperatureUnit"`
ModeAvlList struct {
AutoMode int `json:"autoMode"`
FanMode int `json:"fanMode"`
} `json:"modeAvlList"`
CoordinableFlg bool `json:"coordinableFlg"`
Parameters DeviceParamList `json:"parameters"`
} `json:"deviceList"`
} `json:"groupList"`
}
func addJsonElement(name string, value string) string {
return `"` + name + `":"` + value + `"`
}
func (dlg DeviceGroupList) Print() {
w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0)
fmt.Fprintln(w, "|\tGroup\t|\tDevice Name\t|\tDeviceGUID\t|")
fmt.Fprintln(w, "|\t-\t|\t-\t|\t-\t|")
for _, group := range dlg.GroupList {
for _, device := range group.DeviceList {
fmt.Fprintln(w, "|\t"+group.GroupName+"\t|\t"+device.DeviceName+"\t|\t"+device.DeviceGUID+"\t|")
}
}
w.Flush()
}
func (dsf DeviceStatusFull) Print() {
t := time.Unix(dsf.Timestamp/1000, 0)
fmt.Println("Device Clock: " + t.Format("2006.01.02 15:04:05"))
//color print
var power string
if dsf.Parameters.Operate == 0 {
power = "Off"
} else {
power = "On"
}
var mode string
switch dsf.Parameters.OperationMode {
case 0:
mode = "Auto"
case 1:
mode = "Dry"
case 2:
mode = "Cool"
case 3:
mode = "Heat"
case 4:
mode = "Nanoe"
}
var eco string
if dsf.Parameters.EcoMode == 0 {
eco = "None"
} else if dsf.Parameters.EcoMode == 1 {
eco = "Strong"
} else if dsf.Parameters.EcoMode == 2 {
eco = "Quiet"
}
var fanSpeed string
switch dsf.Parameters.FanSpeed {
case 0:
fanSpeed = "auto"
case 1:
fanSpeed = "1"
case 2:
fanSpeed = "2"
case 3:
fanSpeed = "3"
case 4:
fanSpeed = "4"
case 5:
fanSpeed = "5"
}
var airSwingUD string
switch dsf.Parameters.FanSpeed {
case 0:
airSwingUD = "Top"
case 1:
airSwingUD = "Bottom"
case 2:
airSwingUD = "Center"
case 3:
airSwingUD = "Center-High"
case 4:
airSwingUD = "Center-Low"
}
var airSwingLR string
switch dsf.Parameters.FanSpeed {
case 0:
airSwingLR = "Left"
case 1:
airSwingLR = "Right"
case 2:
airSwingLR = "Center"
case 4:
airSwingLR = "Center-Left"
case 5:
airSwingLR = "Center-Right"
}
switch dsf.Parameters.FanAutoMode {
case 3:
airSwingLR = "auto"
case 2:
airSwingUD = "auto"
case 0:
airSwingLR = "auto"
airSwingUD = "auto"
}
w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0)
//Graphs with bars or something
fmt.Fprintln(w, "|\tPower: "+power+" \t|\t Mode: "+mode+" \t|\t Eco mode: "+eco+"\t|")
fmt.Fprintln(w, "|\tFan Speed: "+fanSpeed+" \t|\t Vertical Angle: "+airSwingUD+" \t|\t Horizontal Angle: "+airSwingLR+"\t|")
fmt.Fprintln(w, "|\tTarget temp: "+strconv.FormatFloat(dsf.Parameters.TemperatureSet, 'f', 1, 64)+"°C \t|\t Inside temp: "+strconv.Itoa(dsf.Parameters.InsideTemperature)+"°C \t|\t Outside temp: "+strconv.Itoa(dsf.Parameters.OutTemperature)+"°C\t|")
w.Flush()
}