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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
use chrono::{NaiveDate, NaiveDateTime};
use serde::Deserialize;
use super::{
DateSerde,
DateTimeSerde,
DateTimeSerdeOpt,
enums::{InverterMode, OperationMode, SiteStatus, TimeUnit},
};
#[derive(Debug, Deserialize)]
pub struct VersionSpec {
pub release: String,
}
#[derive(Debug, Deserialize)]
pub struct VersionCurrentTop {
pub version: VersionSpec,
}
#[derive(Debug, Deserialize)]
pub struct VersionSupportedTop {
pub supported: Vec<VersionSpec>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Location {
pub country: String,
pub city: String,
pub address: String,
pub address2: String,
pub zip: String,
pub time_zone: String,
pub country_code: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Module {
pub manufacturer_name: String,
pub model_name: String,
pub maximum_power: f64,
pub temperature_coef: f64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub struct SiteUris {
pub details: String,
pub data_period: String,
pub overview: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PublicSettings {
pub name: Option<String>,
pub is_public: bool,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Site {
pub id: u64,
pub name: String,
pub account_id: u64,
pub status: SiteStatus,
pub peak_power: f64,
#[serde(with = "DateTimeSerde")]
pub last_update_time: NaiveDateTime,
pub currency: String,
#[serde(with = "DateTimeSerde")]
pub installation_date: NaiveDateTime,
#[serde(with = "DateTimeSerdeOpt")]
pub pto_date: Option<NaiveDateTime>,
pub notes: String,
#[serde(rename = "type")]
pub typ: String,
pub location: Location,
pub primary_module: Module,
pub alert_quantity: Option<u32>,
pub alert_severity: Option<String>,
pub uris: SiteUris,
pub public_settings: PublicSettings,
}
#[derive(Debug, Deserialize)]
pub struct SitesListSites {
pub count: usize,
pub site: Vec<Site>,
}
#[derive(Debug, Deserialize)]
pub struct SitesListTop {
pub sites: SitesListSites,
}
#[derive(Debug, Deserialize)]
pub struct SiteDetailsTop {
pub details: Site,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DataPeriod {
#[serde(with = "DateTimeSerdeOpt")]
pub start_date: Option<NaiveDateTime>,
#[serde(with = "DateTimeSerdeOpt")]
pub end_date: Option<NaiveDateTime>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteDataPeriodTop {
pub data_period: DataPeriod,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteDateValue {
#[serde(with = "DateTimeSerde")]
date: NaiveDateTime,
value: Option<f64>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteEnergy {
pub time_unit: TimeUnit,
pub unit: String,
pub values: Vec<SiteDateValue>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteEnergyTop {
pub energy: SiteEnergy,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteLifetimeEnergy {
#[serde(with = "DateSerde")]
date: NaiveDate,
energy: f64,
unit: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteTimeframeEnergy {
pub energy: f64,
pub unit: String,
pub measured_by: String,
pub start_lifetime_energy: SiteLifetimeEnergy,
pub end_lifetime_energy: SiteLifetimeEnergy,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteTimeframeEnergyTop {
#[serde(rename = "timeFrameEnergy")]
pub timeframe_energy: SiteTimeframeEnergy,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SitePower {
pub time_unit: TimeUnit,
pub unit: String,
pub values: Vec<SiteDateValue>,
}
#[derive(Debug, Deserialize)]
pub struct SitePowerTop {
pub power: SitePower,
}
#[derive(Debug, Deserialize)]
pub struct SiteEnergyData {
pub energy: f64,
pub revenue: Option<f64>,
}
#[derive(Debug, Deserialize)]
pub struct SitePowerData {
pub power: f64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteOverview {
#[serde(with = "DateTimeSerde")]
pub last_update_time: NaiveDateTime,
#[serde(rename = "lifeTimeData")]
pub lifetime_data: SiteEnergyData,
pub last_year_data: SiteEnergyData,
pub last_month_data: SiteEnergyData,
pub last_day_data: SiteEnergyData,
pub current_power: SitePowerData,
pub measured_by: String,
}
#[derive(Debug, Deserialize)]
pub struct SiteOverviewTop {
pub overview: SiteOverview,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteMeterValue {
#[serde(rename = "type")]
pub typ: String,
pub values: Vec<SiteDateValue>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteMetersDetails {
pub time_unit: TimeUnit,
pub unit: String,
pub meters: Vec<SiteMeterValue>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SitePowerDetailsTop {
pub power_details: SiteMetersDetails,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteEnergyDetailsTop {
pub energy_details: SiteMetersDetails,
}
#[derive(Debug, Deserialize)]
pub struct PowerConnection {
pub from: String,
pub to: String,
}
#[derive(Debug, Deserialize)]
pub struct SiteCurrentPowerFlow {
pub unit: Option<String>,
pub connections: Option<Vec<PowerConnection>>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteCurrentPowerFlowTop {
pub site_current_power_flow: SiteCurrentPowerFlow,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BatteryTelemetry {
#[serde(rename = "timeStamp", with = "DateTimeSerde")]
pub timestamp: NaiveDateTime,
pub power: u32,
pub battery_state: u32,
#[serde(rename = "lifeTimeEnergyCharged")]
pub lifetime_energy_charged: u32,
#[serde(rename = "lifeTimeEnergyDischarged")]
pub lifetime_energy_discharged: u32,
pub full_pack_energy_available: u32,
pub internal_temp: u32,
#[serde(rename = "ACGridCharging")]
pub ac_grid_charging: u32,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageBattery {
pub nameplate: String,
pub serial_number: String,
pub model_number: String,
pub telemetry_count: usize,
pub telemetries: Vec<BatteryTelemetry>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteStorageData {
pub battery_count: usize,
pub batteries: Vec<StorageBattery>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SiteStorageDataTop {
pub storage_data: SiteStorageData,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Meter {
pub name: String,
pub manufacturer: String,
pub model: String,
pub firmware_version: String,
#[serde(rename = "connectedSolaredgeDeviceSN")]
pub connected_solaredge_device_sn: String,
#[serde(rename = "type")]
pub typ: String,
pub form: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Sensor {
#[serde(rename = "connectedSolaredgeDeviceSN")]
pub connected_solaredge_device_sn: String,
pub id: String,
pub connected_to: String,
pub category: String,
#[serde(rename = "type")]
pub typ: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Gateway {
pub name: String,
pub firmware_version: String,
#[serde(rename = "SN")]
pub sn: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Battery {
pub name: String,
pub manufacturer: String,
pub model: String,
pub firmware_version: String,
pub connected_inverter_sn: String,
pub nameplate_capacity: f64,
#[serde(rename = "SN")]
pub sn: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Inverter {
pub name: String,
pub manufacturer: String,
pub model: String,
pub communication_method: String,
#[serde(rename = "SN")]
pub sn: String,
pub connected_optimizers: u32,
}
#[derive(Debug, Deserialize)]
pub struct SiteInventory {
pub meters: Vec<Meter>,
pub sensors: Vec<Sensor>,
pub gateways: Vec<Gateway>,
pub batteries: Vec<Battery>,
pub inverters: Vec<Inverter>,
}
#[derive(Debug, Deserialize)]
pub struct SiteInventoryTop {
#[serde(rename = "Inventory")]
pub inventory: SiteInventory,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Equipment {
pub name: String,
pub manufacturer: String,
pub model: String,
pub serial_number: String,
#[serde(rename = "kWpDC")]
pub kw_p_dc: Option<f64>,
}
#[derive(Debug, Deserialize)]
pub struct EquipmentReporters {
pub count: usize,
pub list: Vec<Equipment>,
}
#[derive(Debug, Deserialize)]
pub struct EquipmentListTop {
pub reporters: EquipmentReporters,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LData {
pub ac_current: f64,
pub ac_voltage: f64,
pub ac_frequency: f64,
pub apparent_power: f64,
pub active_power: f64,
pub reactive_power: f64,
pub cos_phi: f64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EquipmentTelemetry {
#[serde(with = "DateTimeSerde")]
pub date: NaiveDateTime,
pub total_active_power: f64,
pub dc_voltage: Option<f64>,
pub ground_fault_resistance: Option<f64>,
pub power_limit: f64,
pub total_energy: f64,
pub temperature: f64,
pub inverter_mode: InverterMode,
pub operation_mode: OperationMode,
#[serde(rename = "L1Data")]
pub l1_data: LData,
#[serde(rename = "vL1To2")]
pub v_l1_to_2: Option<f64>,
#[serde(rename = "vL2To3")]
pub v_l2_to_3: Option<f64>,
#[serde(rename = "vL3To1")]
pub v_l3_to_1: Option<f64>,
#[serde(rename = "L2Data")]
pub l2_data: Option<LData>,
#[serde(rename = "L3Data")]
pub l3_data: Option<LData>,
}
#[derive(Debug, Deserialize)]
pub struct EquipmentData {
pub count: usize,
pub telemetries: Vec<EquipmentTelemetry>,
}
#[derive(Debug, Deserialize)]
pub struct EquipmentDataTop {
pub data: EquipmentData,
}