-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.go
422 lines (375 loc) · 15.1 KB
/
types.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
package sensonet
import (
"time"
)
const (
CLIENT_ID = "myvaillant"
REDIRECT_URL = "enduservaillant.page.link://login"
AUTH_BASE_URL = "https://identity.vaillant-group.com/auth/realms"
LOGIN_URL = AUTH_BASE_URL + "/%s/login-actions/authenticate"
TOKEN_URL = AUTH_BASE_URL + "/%s/protocol/openid-connect/token"
AUTH_URL = AUTH_BASE_URL + "/%s/protocol/openid-connect/auth"
API_URL_BASE = "https://api.vaillant-group.com/service-connected-control/end-user-app-api/v1"
HOTWATERBOOST_URL = "/systems/%s/tli/domestic-hot-water/%01d/boost"
ZONEQUICKVETO_URL = "/systems/%s/tli/zones/%01d/quick-veto"
SYSTEMS_URL = "/systems/%s/tli"
DEVICES_URL = "/emf/v2/%s/currentSystem"
ENERGY_URL = "/emf/v2/%s/devices/%s/buckets?"
MPC_URL = "/hem/%s/mpc"
)
const (
HOTWATERINDEX_DEFAULT = 255
ZONEINDEX_DEFAULT = 0
ZONEVETOSETPOINT_DEFAULT = 20.0
ZONEVETODURATION_DEFAULT = 3.0 // 3 hours as default
OPERATIONMODE_TIME_CONTROLLED string = "TIME_CONTROLLED"
QUICKMODE_HOTWATER string = "Hotwater Boost"
QUICKMODE_HEATING string = "Heating Quick Veto"
QUICKMODE_NOTHING string = "Charger running idle"
QUICKMODE_ERROR_ALREADYON string = "Error. A quickmode is already running"
SPECIAL_FUNCTION_QUICK_VETO = "QUICK_VETO"
SPECIAL_FUNCTION_HOTWATER_BOOST = "CYLINDER_BOOST"
)
const (
STRATEGY_NONE = 0
STRATEGY_HOTWATER = 1
STRATEGY_HEATING = 2
STRATEGY_HOTWATER_THEN_HEATING = 3
)
const (
DEVICES_ALL = 0
DEVICES_PRIMARY_HEATER = 1
DEVICES_SECONDARY_HEATER = 2
DEVICES_BACKUP_HEATER = 3
)
const (
RESOLUTION_HOUR = "HOUR"
RESOLUTION_DAY = "DAY"
RESOLUTION_MONTH = "MONTH"
)
type Logger interface {
Printf(msg string, arg ...any)
}
type CredentialsStruct struct {
User string `json:"user"`
Password string `json:"password"`
Realm string `json:"realm"`
}
type HeatingParStruct struct {
ZoneIndex int
VetoSetpoint float32
VetoDuration float32
}
type HotwaterParStruct struct {
Index int
}
type Homes []struct {
HomeName string `json:"homeName"`
Address struct {
Street string `json:"street"`
Extension any `json:"extension"`
City string `json:"city"`
PostalCode string `json:"postalCode"`
CountryCode string `json:"countryCode"`
} `json:"address"`
SerialNumber string `json:"serialNumber"`
SystemID string `json:"systemId"`
ProductMetadata struct {
ProductType string `json:"productType"`
ProductionYear string `json:"productionYear"`
ProductionWeek string `json:"productionWeek"`
ArticleNumber string `json:"articleNumber"`
} `json:"productMetadata"`
State string `json:"state"`
MigrationState string `json:"migrationState"`
MigrationFinishedAt time.Time `json:"migrationFinishedAt"`
OnlineState string `json:"onlineState"`
Firmware struct {
Version string `json:"version"`
UpdateEnabled bool `json:"updateEnabled"`
UpdateRequired bool `json:"updateRequired"`
} `json:"firmware"`
Nomenclature string `json:"nomenclature"`
Cag bool `json:"cag"`
CountryCode string `json:"countryCode"`
ProductInformation string `json:"productInformation"`
FirmwareVersion string `json:"firmwareVersion"`
}
type SystemStatus struct {
State struct {
System struct {
OutdoorTemperature float64 `json:"outdoorTemperature"`
OutdoorTemperatureAverage24H float64 `json:"outdoorTemperatureAverage24h"`
SystemFlowTemperature float64 `json:"systemFlowTemperature"`
SystemWaterPressure float64 `json:"systemWaterPressure"`
EnergyManagerState string `json:"energyManagerState"`
SystemOff bool `json:"systemOff"`
} `json:"system"`
Zones []StateZone `json:"zones"`
Circuits []StateCircuit `json:"circuits"`
Dhw []StateDhw `json:"dhw"`
DomesticHotWater []StateDomesticHotWater `json:"domesticHotWater"`
// Ventilations
} `json:"state"`
Properties struct {
System struct {
ControllerType string `json:"controllerType"`
SystemScheme int `json:"systemScheme"`
BackupHeaterType string `json:"backupHeaterType"`
BackupHeaterAllowedFor string `json:"backupHeaterAllowedFor"`
ModuleConfigurationVR71 int `json:"moduleConfigurationVR71"`
EnergyProvidePowerCutBehavior string `json:"energyProvidePowerCutBehavior"`
SmartPhotovoltaicBufferOffset float64 `json:"smartPhotovoltaicBufferOffset"`
ExternalEnergyManagementActivation bool `json:"externalEnergyManagementActivation"`
} `json:"system"`
Zones []PropertiesZone `json:"zones"`
Circuits []PropertiesCircuit `json:"circuits"`
Dhw []PropertiesDhw `json:"dhw"`
DomesticHotWater []PropertiesDomesticHotWater `json:"domesticHotWater"`
// Ventilations
} `json:"properties"`
Configuration struct {
System struct {
ContinuousHeatingStartSetpoint float64 `json:"continuousHeatingStartSetpoint"`
AlternativePoint float64 `json:"alternativePoint"`
HeatingCircuitBivalencePoint float64 `json:"heatingCircuitBivalencePoint"`
DhwBivalencePoint float64 `json:"dhwBivalencePoint"`
AdaptiveHeatingCurve bool `json:"adaptiveHeatingCurve"`
DhwMaximumLoadingTime int `json:"dhwMaximumLoadingTime"`
DhwHysteresis float64 `json:"dhwHysteresis"`
DhwFlowSetpointOffset float64 `json:"dhwFlowSetpointOffset"`
ContinuousHeatingRoomSetpoint float64 `json:"continuousHeatingRoomSetpoint"`
HybridControlStrategy string `json:"hybridControlStrategy"`
MaxFlowSetpointHpError float64 `json:"maxFlowSetpointHpError"`
DhwMaximumTemperature float64 `json:"dhwMaximumTemperature"`
MaximumPreheatingTime int `json:"maximumPreheatingTime"`
ParalellTankLoadingAllowed bool `json:"paralellTankLoadingAllowed"`
} `json:"system"`
Zones []ConfigurationZone `json:"zones"`
Circuits []ConfigurationCircuit `json:"circuits"`
Dhw []ConfigurationDhw `json:"dhw"`
DomesticHotWater []ConfigurationDomesticHotWater `json:"domesticHotWater"`
// Ventilations
} `json:"configuration"`
}
type DhwData struct {
State StateDhw
Properties PropertiesDhw
Configuration ConfigurationDhw
}
type DomesticHotWaterData struct {
State StateDomesticHotWater
Properties PropertiesDomesticHotWater
Configuration ConfigurationDomesticHotWater
}
type ZoneData struct {
State StateZone
Properties PropertiesZone
Configuration ConfigurationZone
}
type SystemAndStatus struct {
SystemId string
SystemStatus SystemStatus
}
type AllSystems struct {
SystemsAndStatus []SystemAndStatus
}
type StateZone struct {
Index int `json:"index"`
DesiredRoomTemperatureSetpointHeating float64 `json:"desiredRoomTemperatureSetpointHeating"`
DesiredRoomTemperatureSetpoint float64 `json:"desiredRoomTemperatureSetpoint"`
CurrentRoomTemperature float64 `json:"currentRoomTemperature,omitempty"`
CurrentRoomHumidity float64 `json:"currentRoomHumidity,omitempty"`
CurrentSpecialFunction string `json:"currentSpecialFunction"`
HeatingState string `json:"heatingState"`
}
type StateCircuit struct {
Index int `json:"index"`
CircuitState string `json:"circuitState"`
CurrentCircuitFlowTemperature float64 `json:"currentCircuitFlowTemperature,omitempty"`
HeatingCircuitFlowSetpoint float64 `json:"heatingCircuitFlowSetpoint"`
CalculatedEnergyManagerState string `json:"calculatedEnergyManagerState"`
}
type StateDhw struct {
Index int `json:"index"`
CurrentSpecialFunction string `json:"currentSpecialFunction"`
CurrentDhwTemperature float64 `json:"currentDhwTemperature"`
}
type StateDomesticHotWater struct {
Index int `json:"index"`
CurrentSpecialFunction string `json:"currentSpecialFunction"`
CurrentDomesticHotWaterTemperature float64 `json:"currentDomesticHotWaterTemperature"`
}
type PropertiesZone struct {
Index int `json:"index"`
IsActive bool `json:"isActive"`
ZoneBinding string `json:"zoneBinding"`
IsCoolingAllowed bool `json:"isCoolingAllowed"`
AssociatedCircuitIndex int `json:"associatedCircuitIndex"`
}
type PropertiesCircuit struct {
Index int `json:"index"`
MixerCircuitTypeExternal string `json:"mixerCircuitTypeExternal"`
HeatingCircuitType string `json:"heatingCircuitType"`
}
type PropertiesDhw struct {
Index int `json:"index"`
MinSetpoint float64 `json:"minSetpoint"`
MaxSetpoint float64 `json:"maxSetpoint"`
}
type PropertiesDomesticHotWater struct {
Index int `json:"index"`
MinSetpoint float64 `json:"minSetpoint"`
MaxSetpoint float64 `json:"maxSetpoint"`
}
type TimeSlot struct {
StartTime int `json:"startTime"`
EndTime int `json:"endTime"`
}
type Setpoint struct {
StartTime int `json:"startTime"`
EndTime int `json:"endTime"`
Setpoint float64 `json:"setpoint"`
}
type MetaInfo struct {
MinSlotsPerDay int `json:"minSlotsPerDay"`
MaxSlotsPerDay int `json:"maxSlotsPerDay"`
SetpointRequiredPerSlot bool `json:"setpointRequiredPerSlot"`
}
type TimeProgram struct {
MetaInfo MetaInfo `json:"metaInfo"`
Monday []Setpoint `json:"monday"`
Tuesday []Setpoint `json:"tuesday"`
Wednesday []Setpoint `json:"wednesday"`
Thursday []Setpoint `json:"thursday"`
Friday []Setpoint `json:"friday"`
Saturday []Setpoint `json:"saturday"`
Sunday []Setpoint `json:"sunday"`
}
type ConfigurationZone struct {
Index int `json:"index"`
General struct {
Name string `json:"name"`
HolidayStartDateTime time.Time `json:"holidayStartDateTime"`
HolidayEndDateTime time.Time `json:"holidayEndDateTime"`
HolidaySetpoint float64 `json:"holidaySetpoint"`
} `json:"general"`
Heating struct {
OperationModeHeating string `json:"operationModeHeating"`
SetBackTemperature float64 `json:"setBackTemperature"`
ManualModeSetpointHeating float64 `json:"manualModeSetpointHeating"`
TimeProgramHeating TimeProgram `json:"timeProgramHeating"`
} `json:"heating"`
}
type ConfigurationCircuit struct {
Index int `json:"index"`
HeatingCurve float64 `json:"heatingCurve"`
HeatingFlowTemperatureMinimumSetpoint float64 `json:"heatingFlowTemperatureMinimumSetpoint"`
HeatingFlowTemperatureMaximumSetpoint float64 `json:"heatingFlowTemperatureMaximumSetpoint"`
HeatDemandLimitedByOutsideTemperature float64 `json:"heatDemandLimitedByOutsideTemperature"`
HeatingCircuitFlowSetpointExcessOffset float64 `json:"heatingCircuitFlowSetpointExcessOffset"`
SetBackModeEnabled bool `json:"setBackModeEnabled"`
RoomTemperatureControlMode string `json:"roomTemperatureControlMode"`
}
type ConfigurationDhw struct {
Index int `json:"index"`
OperationModeDhw string `json:"operationModeDhw"`
TappingSetpoint float64 `json:"tappingSetpoint"`
HolidayStartDateTime time.Time `json:"holidayStartDateTime"`
HolidayEndDateTime time.Time `json:"holidayEndDateTime"`
TimeProgramDhw TimeProgram `json:"timeProgramDhw"`
TimeProgramCirculationPump TimeProgram `json:"timeProgramCirculationPump"`
}
type ConfigurationDomesticHotWater struct {
Index int `json:"index"`
OperationModeDomesticHotWater string `json:"operationModeDomesticHotWater"`
TappingSetpoint float64 `json:"tappingSetpoint"`
HolidayStartDateTime time.Time `json:"holidayStartDateTime"`
HolidayEndDateTime time.Time `json:"holidayEndDateTime"`
TimeProgramDomesticHotWater TimeProgram `json:"timeProgramDomesticHotWater"`
TimeProgramCirculationPump TimeProgram `json:"timeProgramCirculationPump"`
}
type EnergyData struct {
ExtraFields struct {
Timezone string `json:"timezone"`
} `json:"extra_fields"`
OperationMode string `json:"operationMode"`
// SkipDataUpdate bool `json:"skip_data_update"`
// DataFrom any `json:"data_from"`
// DataTo any `json:"data_to"`
StartDate time.Time `json:"startDate"`
EndDate time.Time `json:"endDate"`
Resolution string `json:"resolution"`
EnergyType string `json:"energyType"`
// ValueType any `json:"valueType"`
// Calculated any `json:"calculated"`
TotalConsumption float64 `json:"totalConsumption"`
Data []struct {
ExtraFields struct {
Timezone string `json:"timezone"`
} `json:"extra_fields"`
StartDate time.Time `json:"startDate"`
EndDate time.Time `json:"endDate"`
Value float64 `json:"value"`
} `json:"data"`
}
type Device struct {
DeviceUUID string `json:"device_uuid"`
EbusID string `json:"ebus_id"`
Spn int `json:"spn"`
BusCouplerAddress int `json:"bus_coupler_address"`
ArticleNumber string `json:"article_number"`
EmfValid bool `json:"emfValid"`
DeviceSerialNumber string `json:"device_serial_number"`
DeviceType string `json:"device_type"`
FirstData time.Time `json:"first_data"`
LastData time.Time `json:"last_data"`
Data []struct {
OperationMode string `json:"operation_mode"`
ValueType string `json:"value_type"`
Calculated bool `json:"calculated"`
From time.Time `json:"from"`
To time.Time `json:"to"`
} `json:"data"`
ProductName string `json:"product_name"`
}
type SystemDevices struct {
SystemType string `json:"system_type"`
HasEmfCapableDevices bool `json:"has_emf_capable_devices"`
PrimaryHeatGenerator Device `json:"primary_heat_generator"`
SecondaryHeatGenerators []Device `json:"secondary_heat_generators"`
ElectricBackupHeater Device `json:"electric_backup_heater"`
SolarStation any `json:"solar_station"`
Ventilation any `json:"ventilation"`
Gateway any `json:"gateway"`
}
type DeviceAndInfo struct {
Device Device
Info string
}
type SystemDevicesAndSystemId struct {
SystemId string
SystemDevices SystemDevices
}
type AllSystemDevices struct {
SystemDevicesAndSystemId []SystemDevicesAndSystemId
}
type MpcData struct {
Devices []MpcDevice `json:"devices"`
}
type MpcDevice struct {
DeviceID string `json:"deviceId"`
CurrentPower float64 `json:"currentPower"`
}
type SystemMpcData struct {
SystemId string
MpcData MpcData
}
type AllSystemMpcData struct {
SystemMpcData []SystemMpcData
}
type DevicePower struct {
CurrentPower float64
ProductName string
}
type DevicePowerMap map[string]DevicePower