aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-14 22:54:26 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-14 22:54:26 -0500
commit5755c3e714041281a5224d4eaa540b86ddb420af (patch)
treefd6ecf7f15e1aaa77e95f907c041e4bebc85b7ec
parent8965587341cfe39f97d36eda052aae4d0040526e (diff)
Added base functions and struct for groups.
-rw-r--r--group.go51
-rw-r--r--group_test.go21
-rw-r--r--schedule.go2
3 files changed, 73 insertions, 1 deletions
diff --git a/group.go b/group.go
new file mode 100644
index 0000000..0ebdcb5
--- /dev/null
+++ b/group.go
@@ -0,0 +1,51 @@
+/*
+* group.go
+* GoHue library for Philips Hue
+* Copyright (C) 2016 Collin Guarino (Collinux) collin.guarino@gmail.com
+* License: GPL version 2 or higher http://www.gnu.org/licenses/gpl.html
+*/
+
+package hue
+
+import (
+ "fmt"
+ "encoding/json"
+)
+
+type Group struct {
+ Action struct {
+ Alert string `json:"alert"`
+ Bri int `json:"bri"`
+ Colormode string `json:"colormode"`
+ Ct int `json:"ct"`
+ Effect string `json:"effect"`
+ Hue int `json:"hue"`
+ On bool `json:"on"`
+ Sat int `json:"sat"`
+ Xy []float64 `json:"xy"`
+ } `json:"action"`
+ Lights []string `json:"lights"`
+ Name string `json:"name"`
+ Type string `json:"type"`
+}
+
+// Bridge.GetGroups get the attributes for each group of lights.
+// TODO: NOT TESTED, NOT FULLY IMPLEMENTED
+func (bridge *Bridge) GetGroups() ([]Group, error) {
+ uri := fmt.Sprintf("/api/%s/groups", bridge.Username)
+ body, _, err := bridge.Get(uri)
+ if err != nil {
+ return []Group{}, err
+ }
+
+ fmt.Println("GROUP GET: ", string(body))
+
+ groups := map[string]Group{}
+ err = json.Unmarshal(body, &groups)
+ if err != nil {
+ return []Group{}, err
+ }
+ fmt.Println("GROUPS: ", groups)
+
+ return []Group{}, nil
+}
diff --git a/group_test.go b/group_test.go
new file mode 100644
index 0000000..8fcbd09
--- /dev/null
+++ b/group_test.go
@@ -0,0 +1,21 @@
+/*
+* group_test.go
+* GoHue library for Philips Hue
+* Copyright (C) 2016 Collin Guarino (Collinux) collin.guarino@gmail.com
+* License: GPL version 2 or higher http://www.gnu.org/licenses/gpl.html
+*/
+
+package hue
+
+import (
+ "testing"
+ "fmt"
+)
+
+func TestGetGroups(t *testing.T) {
+ bridge, _ := NewBridge("192.168.1.128", "427de8bd6d49f149c8398e4fc08f")
+ groups, _ := bridge.GetGroups()
+ for group := range groups {
+ fmt.Println(groups[group])
+ }
+}
diff --git a/schedule.go b/schedule.go
index ce139e8..c586e1d 100644
--- a/schedule.go
+++ b/schedule.go
@@ -74,6 +74,7 @@ func (bridge *Bridge) GetSchedule(id string) (Schedule, error) {
return schedule, nil
}
+// TODO: NOT TESTED, NOT FULLY IMPLEMENTED
func (bridge *Bridge) CreateSchedule(schedule Schedule) error {
uri := fmt.Sprintf("/api/%s/schedules", bridge.Username)
body, _, err := bridge.Post(uri, schedule)
@@ -82,7 +83,6 @@ func (bridge *Bridge) CreateSchedule(schedule Schedule) error {
}
fmt.Println("CREATE SCHEDULE BODY: ", string(body))
- // TODO: Not tested or fully implemented
return nil
}