-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexporter_test.go
47 lines (41 loc) · 1.03 KB
/
exporter_test.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
package main
import (
"context"
"fmt"
"os"
"testing"
"time"
"github.com/setheck/smartthings-exporter/smartthings"
)
func TestPlayground(t *testing.T) {
t.SkipNow()
client := smartthings.NewClient(os.Getenv("STE_API_TOKEN"), nil)
devices, err := client.ListDevices(context.TODO())
if err != nil {
t.Fatal(err)
}
for _, device := range devices {
for _, component := range device.Components {
cs, err := client.GetDeviceComponentStatus(context.TODO(), device.DeviceID, component.ID)
if err != nil {
fmt.Println(err)
//t.Fatal(err)
} else {
//fmt.Println(cs)
for capabilityId, attributes := range cs {
for attributeId, properties := range attributes {
if value, ok := properties["value"]; ok {
fmt.Println("capabilityId:", capabilityId, "attribute:", attributeId, "value:", value)
}
}
}
}
}
}
}
func TestParseTime(t *testing.T) {
t.SkipNow()
ts := "2020-12-03T06:41:54.441Z"
tm, _ := time.Parse(time.RFC3339Nano, ts)
fmt.Println(tm.UnixNano() / int64(time.Millisecond))
}