aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brunner <chb@muc.de>2016-09-13 22:22:27 +0200
committerChristian Brunner <chb@muc.de>2016-09-15 17:56:45 +0200
commit8ce825db2570d06a868fd89cb7518cad6169284e (patch)
tree996a44e7cdfb20cae1a8d9ae5329388b0abadcb8
parent15a6d3afe17915ca077696abc58145db27d9601c (diff)
add SetGroupState()
-rw-r--r--group.go36
1 files changed, 25 insertions, 11 deletions
diff --git a/group.go b/group.go
index 4a36346..c842a5a 100644
--- a/group.go
+++ b/group.go
@@ -13,19 +13,23 @@ import (
"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 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"`
+ Action Action `json:"action"`
Lights []string `json:"lights"`
Name string `json:"name"`
Type string `json:"type"`
@@ -51,3 +55,13 @@ func (bridge *Bridge) GetGroups() ([]Group, error) {
return []Group{}, nil
}
+
+// Bridge.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
+}