-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinverter.go
46 lines (43 loc) · 1.27 KB
/
inverter.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
package growatt
// Inverter represents the datastructure for a Growatt inverter
type Inverter struct {
IsLost bool
InverterType string
EnergyToday float64 // in kilowatthours
EnergyTotal float64 // in kilowatthours
Location string
Alias string
Type string
DatalogSerial string
Serial string
CurrentPower float64 // in watts
Status int
}
type inverterData struct {
Lost bool `json:"lost"`
InverterType string `json:"invType"`
EnergyToday string `json:"eToday"`
Location string `json:"location"`
Alias string `json:"deviceAilas"`
Type string `json:"deviceType"`
DatalogSerial string `json:"datalogSn"`
Serial string `json:"deviceSn"`
CurrentPower string `json:"power"`
Status int `json:"deviceStatus"`
EnergyTotal string `json:"energy"`
}
func parseInvertedData(i inverterData) Inverter {
return Inverter{
IsLost: i.Lost,
InverterType: i.InverterType,
EnergyToday: parsePower(i.EnergyToday),
EnergyTotal: parsePower(i.EnergyTotal),
Location: i.Location,
Alias: i.Alias,
Type: i.Type,
DatalogSerial: i.DatalogSerial,
Serial: i.Serial,
CurrentPower: parsePower(i.CurrentPower),
Status: i.Status,
}
}