aboutsummaryrefslogtreecommitdiff
path: root/group.go
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 /group.go
parent8965587341cfe39f97d36eda052aae4d0040526e (diff)
Added base functions and struct for groups.
Diffstat (limited to 'group.go')
-rw-r--r--group.go51
1 files changed, 51 insertions, 0 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
+}