aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/benburwell/gohue/group.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/benburwell/gohue/group.go')
-rw-r--r--vendor/github.com/benburwell/gohue/group.go67
1 files changed, 67 insertions, 0 deletions
diff --git a/vendor/github.com/benburwell/gohue/group.go b/vendor/github.com/benburwell/gohue/group.go
new file mode 100644
index 0000000..db878d6
--- /dev/null
+++ b/vendor/github.com/benburwell/gohue/group.go
@@ -0,0 +1,67 @@
+/*
+* 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
+ */
+// http://www.developers.meethue.com/documentation/groups-api
+
+package hue
+
+import (
+ "encoding/json"
+ "fmt"
+)
+
+// Action struct defines the state of a group
+type Action struct {
+ Alert string `json:"alert,omitempty"`
+ Bri int `json:"bri,omitempty"`
+ Colormode string `json:"colormode,omitempty"`
+ Ct int `json:"ct,omitempty"`
+ Effect string `json:"effect,omitempty"`
+ Hue *int `json:"hue,omitempty"`
+ On *bool `json:"on,omitempty"`
+ Sat *int `json:"sat,omitempty"`
+ XY []float64 `json:"xy,omitempty"`
+ Scene string `json:"scene,omitempty"`
+}
+
+// Group struct defines the attributes for a group of lights.
+type Group struct {
+ Action Action `json:"action"`
+ Lights []string `json:"lights"`
+ Name string `json:"name"`
+ Type string `json:"type"`
+}
+
+// GetGroups gets 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
+}
+
+// SetGroupState sends an action to group
+func (bridge *Bridge) SetGroupState(group int, action *Action) error {
+ uri := fmt.Sprintf("/api/%s/groups/%d/action", bridge.Username, group)
+ _, _, err := bridge.Put(uri, action)
+ if err != nil {
+ return err
+ }
+ return nil
+}