-
Notifications
You must be signed in to change notification settings - Fork 2
/
sensor.go
56 lines (48 loc) · 1.43 KB
/
sensor.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
package solaredge
/*
type Sensor struct {
ConnectedTo string `json:"connectedTo"`
Count int `json:"count"`
Sensors []struct {
Name string `json:"name"`
Measurement string `json:"measurement"`
Type string `json:"type"`
} `json:"sensors"`
}
// TODO: doesn't return any data?
func (c *Client) GetSensors(ctx context.Context) ([]Sensor, error) {
var output struct {
SiteSensors struct {
Count int `json:"count"`
List []Sensor `json:"list"`
} `json:"SiteSensors"`
}
err := c.call(ctx, "/equipment/%d/sensors", url.Values{}, &output)
return output.SiteSensors.List, err
}
type SensorData struct {
ConnectedTo string `json:"connectedTo"`
Count int `json:"count"`
Telemetries []struct {
// TODO: this list isn't complete in the API documentation
Date Time `json:"date"`
AmbientTemperature float64 `json:"ambientTemperature"`
ModuleTemperature float64 `json:"moduleTemperature"`
WindSpeed float64 `json:"windSpeed"`
} `json:"telemetries"`
}
// TODO: returns 404?
func (c *Client) GetSensorData(ctx context.Context, from, to time.Time) ([]SensorData, error) {
args, err := buildArgsFromTimeRange(from, to, "Date", "2006-01-02 15:04:05")
if err != nil {
return nil, err
}
var output struct {
SiteSensors struct {
Data []SensorData `json:"data"`
}
}
err = c.call(ctx, "/site/%d/sensors", args, &output)
return output.SiteSensors.Data, err
}
*/