forked from cloudkucooland/go-envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
192 lines (178 loc) · 6.53 KB
/
types.go
File metadata and controls
192 lines (178 loc) · 6.53 KB
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
package envoy
import "encoding/xml"
// from the production endpoint
type production struct {
Production []entry `json:"production"`
Consumption []entry `json:"consumption"`
Storage []entry `json:"storage"`
}
type entry struct {
Type string `json:"type"`
ActiveCount int `json:"activeCount"`
MeasurementType string `json:"measurementType"`
ReadingTime int `json:"readingTime"`
WNow float64 `json:"wNow,omitempty"`
WhLifetime float64 `json:"whLifetime,omitempty"`
WhNow float64 `json:"whNow,omitempty"`
VarhLeadLifetime float64 `json:"varhLeadLifetime,omitempty"`
VarhLagLifetime float64 `json:"varhLagLifetime,omitempty"`
VahLifetime float64 `json:"vahLifetime,omitempty"`
RmsCurrent float64 `json:"rmsCurrent,omitempty"`
RmsVoltage float64 `json:"rmsVoltage,omitempty"`
ReactPwr float64 `json:"reactPwr,omitempty"`
ApprntPwr float64 `json:"apprntPwr,omitempty"`
PwrFactor float64 `json:"pwrFactor,omitempty"`
WhToday float64 `json:"whToday,omitempty"`
WhLastSevenDays float64 `json:"whLastSevenDays,omitempty"`
VahToday float64 `json:"vahToday,omitempty"`
VarhLeadToday float64 `json:"varhLeadToday,omitempty"`
VarhLagToday float64 `json:"varhLagToday,omitempty"`
State string `json:"state,omitempty"`
Lines []line `json:"lines,omitempty"`
}
type line struct {
WNow float64 `json:"wNow"`
WhLifetime float64 `json:"whLifetime"`
VarhLeadLifetime float64 `json:"varhLeadLifetime"`
VarhLagLifetime float64 `json:"varhLagLifetime"`
VahLifetime float64 `json:"vahLifetime"`
RmsCurrent float64 `json:"rmsCurrent"`
RmsVoltage float64 `json:"rmsVoltage"`
ReactPwr float64 `json:"reactPwr"`
ApprntPwr float64 `json:"apprntPwr"`
PwrFactor float64 `json:"pwrFactor"`
WhToday float64 `json:"whToday"`
WhLastSevenDays float64 `json:"whLastSevenDays"`
VahToday float64 `json:"vahToday"`
VarhLeadToday float64 `json:"varhLeadToday"`
VarhLagToday float64 `json:"varhLagToday"`
}
// http://envoy.local/home.json
type home struct {
SoftwareBuildEpoch int `json:"software_build_epoch"`
IsNonvoy bool `json:"is_nonvoy"`
DbSize string `json:"db_size"`
DbPercentFull string `json:"db_percent_full"`
Timezone string `json:"timezone"`
CurrentDate string `json:"current_date"`
CurrentTime string `json:"current_time"`
Network homenet `json:"network"`
Tariff string `json:"tariff"`
Comm struct {
Num int `json:"num"`
Level int `json:"level"`
Pcu homenumlev `json:"pcu"`
Acb homenumlev `json:"acb"`
Nsrb homenumlev `json:"nsrb"`
} `json:"comm"`
Alerts []interface{} `json:"alerts"` // dunno on this one yet
UpdateStatus string `json:"update_status"`
}
type homenumlev struct {
Num int `json:"num"`
Level int `json:"level"`
}
type homenet struct {
WebComm bool `json:"web_comm"`
EverReportedToEnlighten bool `json:"ever_reported_to_enlighten"`
LastEnlightenReportTime int `json:"last_enlighten_report_time"`
PrimaryInterface string `json:"primary_interface"`
Interfaces []homenetif `json:"interfaces"`
}
type homenetif struct {
SignalStrength int `json:"signal_strength"`
SignalStrengthMax int `json:"signal_strength_max"`
Network bool `json:"network,omitempty"`
Type string `json:"type"`
Interface string `json:"interface"`
Dhcp bool `json:"dhcp"`
IP string `json:"ip"`
Carrier bool `json:"carrier"`
Mac string `json:"mac,omitempty"`
Supported bool `json:"supported,omitempty"`
Present bool `json:"present,omitempty"`
Configured bool `json:"configured,omitempty"`
Status string `json:"status,omitempty"`
}
// inventory
type inventory struct {
Type string `json:"type"`
Devices []struct {
PartNum string `json:"part_num"`
Installed string `json:"installed"`
SerialNum string `json:"serial_num"`
DeviceStatus []string `json:"device_status"`
LastRptDate string `json:"last_rpt_date"`
AdminState int `json:"admin_state"`
DevType int `json:"dev_type"`
CreatedDate string `json:"created_date"`
ImgLoadDate string `json:"img_load_date"`
ImgPnumRunning string `json:"img_pnum_running"`
Ptpn string `json:"ptpn"`
Chaneid int `json:"chaneid"`
DeviceControl []struct {
Gficlearset bool `json:"gficlearset"`
} `json:"device_control"`
Producing bool `json:"producing"`
Communicating bool `json:"communicating"`
Provisioned bool `json:"provisioned"`
Operating bool `json:"operating"`
} `json:"devices"`
}
// for the stream endpoint
type streamEntry struct {
P float64 `json:"p"`
Q float64 `json:"q"`
S float64 `json:"s"`
V float64 `json:"v"`
I float64 `json:"i"`
Pf float64 `json:"pf"`
F float64 `json:"f"`
}
type streamSet struct {
A streamEntry `json:"ph-a"`
B streamEntry `json:"ph-b"`
C streamEntry `json:"ph-c"`
}
type stream struct {
Production streamSet `json:"production"`
NetConsumption streamSet `json:"net-consumption"`
TotalConsumption streamSet `json:"total-consumption"`
}
type EnvoyInfo struct {
XMLName xml.Name `xml:"envoy_info"`
Text string `xml:",chardata"`
Time string `xml:"time"`
Device struct {
Text string `xml:",chardata"`
Sn string `xml:"sn"`
Pn string `xml:"pn"`
Software string `xml:"software"`
Euaid string `xml:"euaid"`
Seqnum string `xml:"seqnum"`
Apiver string `xml:"apiver"`
Imeter string `xml:"imeter"`
} `xml:"device"`
Package []struct {
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Pn string `xml:"pn"`
Version string `xml:"version"`
Build string `xml:"build"`
} `xml:"package"`
BuildInfo struct {
Text string `xml:",chardata"`
BuildTimeGmt string `xml:"build_time_gmt"`
BuildID string `xml:"build_id"`
} `xml:"build_info"`
}
// requires authentication
// http://envoy.local/api/v1/production/inverters
// uint8 for Watts might be good enough, but mine are hitting 246...
type Inverter struct {
SerialNumber string `json:"serialNumber"`
LastReportDate uint64 `json:"lastReportDate"`
DevType uint8 `json:"devType"`
LastReportWatts int16 `json:"lastReportWatts"`
MaxReportWatts uint16 `json:"maxReportWatts"`
}