/
api.go
281 lines (237 loc) · 9.2 KB
/
api.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
package digitalstrom
// Appartment structure
type Apartment struct {
ApartmentId string `mapstructure:"id"`
Attributes ApartmentAttributes `mapstructure:"attributes"`
Included ApartmentIncluded `mapstructure:"included"`
}
type ApartmentAttributes struct {
Name string `mapstructure:"name"`
Zones []string `mapstructure:"zones"`
Devices []string `mapstructure:"dsDevices"`
Clusters []string `mapstructure:"clusters"`
}
type ApartmentIncluded struct {
// Before mapping this, you need to add the "include" in the query
Installation Installation `mapstructure:"installation"`
Devices []Device `mapstructure:"dsDevices"`
Submodules []Submodule `mapstructure:"submodules"`
FunctionBlocks []FunctionBlock `mapstructure:"functionBlocks"`
Zones []Zone `mapstructure:"zones"`
Controllers []Controller `mapstructure:"controllers"`
Meterings []Metering `mapstructure:"meterings"`
}
type Installation struct {
InstallationId string `mapstructure:"id"`
Type string `mapstructure:"type"`
Attributes InstallationAttribute `mapstructure:"attributes"`
}
type InstallationAttribute struct {
CountryCode string `mapstructure:"countryCode"`
City string `mapstructure:"city"`
Timezone string `mapstructure:"timezone"`
}
type Device struct {
DeviceId string `mapstructure:"id"`
Attributes DeviceAttributes `mapstructure:"attributes"`
}
type DeviceAttributes struct {
Name string `mapstructure:"name"`
Dsid string `mapstructure:"dsid"`
DisplayId string `mapstructure:"displayId"`
Present bool `mapstructure:"present"`
Submodules []string `mapstructure:"submodules"`
Zone string `mapstructure:"zone"`
Scenarios []string `mapstructure:"scenarios"`
Controller string `mapstructure:"controller"`
}
type Submodule struct {
SubmoduleId string `mapstructure:"id"`
Attributes SubmoduleAttributes `mapstructure:"attributes"`
}
type SubmoduleAttributes struct {
Name string `mapstructure:"name"`
TechnicalName string `mapstructure:"technicalName"`
DeviceId string `mapstructure:"dsDevice"`
FunctionBlocks []string `mapstructure:"functionBlocks"`
Zone string `mapstructure:"zone"`
Application SubmoduleApplication `mapstructure:"application"`
Scenarios []string `mapstructure:"scenarios"`
Controller string `mapstructure:"controller"`
}
type FunctionBlock struct {
FunctionBlockId string `mapstructure:"id"`
Attributes FunctionBlockAttributes `mapstructure:"attributes"`
}
type FunctionBlockAttributes struct {
Name string `mapstructure:"name"`
TechnicalName string `mapstructure:"technicalName"`
Active bool `mapstructure:"active"`
Outputs []Output `mapstructure:"outputs"`
ButtonInputs []ButtonInputs `mapstructure:"buttonInputs"`
SensorInputs []SensorInputs `mapstructure:"sensorInputs"`
Submodule string `mapstructure:"submodule"`
DeviceAdapter string `mapstructure:"deviceAdapter"`
}
type Output struct {
OutputId string `mapstructure:"id"`
Attributes OutputAttributes `mapstructure:"attributes"`
}
type OutputAttributes struct {
TechnicalName string `mapstructure:"technicalName"`
Type OutputType `mapstructure:"type"`
Function string `mapstructure:"function"`
Mode OutputMode `mapstructure:"mode"`
Min float64 `mapstructure:"min"`
Max float64 `mapstructure:"max"`
Resolution float64 `mapstructure:"resolution"`
}
type ButtonInputs struct {
ButtonInputId string `mapstructure:"id"`
Attributes ButtonInputsAttributes `mapstructure:"attributes"`
}
type ButtonInputsAttributes struct {
TechnicalName string `mapstructure:"technicalName"`
Type ButtonInputType `mapstructure:"type"`
Mode ButtonInputMode `mapstructure:"mode"`
}
type SensorInputs struct {
SensorInputId string `mapstructure:"id"`
Attributes SensorInputsAttributes `mapstructure:"attributes"`
}
type SensorInputsAttributes struct {
TechnicalName string `mapstructure:"technicalName"`
Type SensorInputType `mapstructure:"type"`
Mode SensorInputUsage `mapstructure:"usage"`
Min float64 `mapstructure:"min"`
Max float64 `mapstructure:"max"`
Resolution float64 `mapstructure:"resolution"`
}
// Zone representation.
type Zone struct {
ZoneId string `mapstructure:"id"`
Attributes ZoneAttributes `mapstructure:"attributes"`
}
type ZoneAttributes struct {
Name string `mapstructure:"name"`
Floor string `mapstructure:"floor"`
OrderId float64 `mapstructure:"orderId"`
Submodules []string `mapstructure:"submodules"`
Applications []string `mapstructure:"applications"`
ApplicationTypes []string `mapstructure:"applicationTypes"`
ApplicationDetails []ApplicationDetail `mapstructure:"applicationDetails"`
}
type ApplicationDetail struct {
ApplicationDetailId string `mapstructure:"id"`
Areas []Area `mapstructure:"areas"`
}
type Area struct {
AreaId string `mapstructure:"id"`
Name string `mapstructure:"name"`
}
type Scenarios struct {
ScenarioId string `mapstructure:"id"`
Type ScenarioType `mapstructure:"type"`
Attributes ScenarioAttributes `mapstructure:"attributes"`
}
type ScenarioAttributes struct {
Name string `mapstructure:"name"`
ActionId string `mapstructure:"actionId"`
Context string `mapstructure:"context"`
Submodules []string `mapstructure:"submodules"`
Devices []string `mapstructure:"dsDevices"`
Zone string `mapstructure:"zone"`
Application ScenarioApplication `mapstructure:"application"`
}
type Controller struct {
ControllerId string `mapstructure:"id"`
Attributes ControllerAttributes `mapstructure:"attributes"`
}
type ControllerAttributes struct {
Name string `mapstructure:"name"`
TechName string `mapstructure:"technicalName"`
}
type Metering struct {
MeteringId string `mapstructure:"id"`
Attributes MeteringAttributes `mapstructure:"attributes"`
}
type MeteringAttributes struct {
Unit string `mapstructure:"unit"`
TechnicalName string `mapstructure:"technicalName"`
Origin MeteringOrigin `mapstructure:"origin"`
}
type MeteringOrigin struct {
MeteringOriginId string `mapstructure:"id"`
Type MeteringType `mapstructure:"type"`
}
// Meterings
type Meterings struct {
Meterings []Metering `mapstructure:"meterings"`
}
type MeteringValues struct {
Values []MeteringValue `mapstructure:"values"`
}
type MeteringValue struct {
Id string `mapstructure:"id"`
Attributes MeteringValueAttributes `mapstructure:"attributes"`
}
type MeteringValueAttributes struct {
Value float64 `json:"value"`
}
// Status
type ApartmentStatus struct {
ApartmentId string `mapstructure:"id"`
Included ApartmentStatusIncluded `mapstructure:"included"`
}
type ApartmentStatusIncluded struct {
Devices []DeviceStatus `mapstructure:"dsDevices"`
}
type DeviceStatus struct {
DeviceId string `mapstructure:"id"`
Type string `mapstructure:"type"`
Attributes DeviceStatusAttributes `mapstructure:"attributes"`
}
type DeviceStatusAttributes struct {
FunctionBlocks []struct {
FunctionBlockId string `mapstructure:"id"`
Outputs []OutputValue `mapstructure:"outputs,omitempty"`
} `mapstructure:"functionBlocks"`
Submodules []struct {
SubmoduleId string `mapstructure:"id"`
OperationsLocked bool `mapstructure:"operationsLocked"`
} `mapstructure:"submodules"`
States []struct {
StateId string `mapstructure:"id"`
Value string `mapstructure:"value"`
} `mapstructure:"states,omitempty"`
}
type OutputValue struct {
OutputId string `mapstructure:"id"`
Value float64 `mapstructure:"value"`
Status OutputValueStatus `mapstructure:"status"`
TargetValue float64 `mapstructure:"targetValue"`
Level int `mapstructure:"level,omitempty"`
}
type SetOutputValue struct {
Op SetOutputValueOperation `json:"op"`
Path string `json:"path"`
Value string `json:"value"`
}
// Websocket
type NotificationType string
const (
NotificationTypeApartmentStructureChanged NotificationType = "apartmentStructureChanged"
NotificationTypeApartmentStatusChanged NotificationType = "apartmentStatusChanged"
)
type WebsocketInitMessage struct {
Protocol string `json:"protocol"`
Version uint32 `json:"version"`
}
type WebsocketNotification struct {
Type int `json:"type"`
Target string `json:"target"`
Arguments []WebsocketNotificationArgument `json:"arguments"`
}
type WebsocketNotificationArgument struct {
Type NotificationType `json:"type"`
}