diff options
author | Collin Guarino <Collinux@users.noreply.github.com> | 2016-09-23 16:18:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-23 16:18:30 -0400 |
commit | e5b3cf00a075a876ce12eb8ee2816043ef8b6fac (patch) | |
tree | 0943188ca8ddc1d451a5f2dda4f25175ae5f026f /group.go | |
parent | 05933eaaf0811a2b2b7d34c814777fd66d2f7ef0 (diff) | |
parent | 717f77eeb3be68ba8328e04f90904070df687d3d (diff) |
Merge pull request #5 from chbmuc/master
Add (scene) functions
Diffstat (limited to 'group.go')
-rw-r--r-- | group.go | 36 |
1 files changed, 25 insertions, 11 deletions
@@ -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 +} |