aboutsummaryrefslogtreecommitdiff
path: root/scene.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-14 23:07:38 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-14 23:07:38 -0500
commitb0913d3b9b7fb9166f24d9e1c7f2212dc7116ce5 (patch)
tree7ec2b8e073b927b2d02f3fc3768eab88f785f1b9 /scene.go
parent1a8b98f271396f412c0ee1b4ca2bf221a3c6a5cc (diff)
Scene struct and Bridge.GetScenes func implementation.
Diffstat (limited to 'scene.go')
-rw-r--r--scene.go44
1 files changed, 43 insertions, 1 deletions
diff --git a/scene.go b/scene.go
index 0db1e1c..fdc4fcd 100644
--- a/scene.go
+++ b/scene.go
@@ -8,5 +8,47 @@
package hue
import (
-
+ "fmt"
+ "encoding/json"
)
+
+type Scene struct {
+ Appdata struct {
+ Data string `json:"data"`
+ Version int `json:"version"`
+ } `json:"appdata"`
+ Lastupdated string `json:"lastupdated"`
+ Lights []string `json:"lights"`
+ Locked bool `json:"locked"`
+ Name string `json:"name"`
+ Owner string `json:"owner"`
+ Picture string `json:"picture"`
+ Recycle bool `json:"recycle"`
+ Version int `json:"version"`
+ ID string
+}
+
+// Bridge.GetScenes will get attributes for all scenes.
+func (bridge *Bridge) GetScenes() ([]Scene, error) {
+ uri := fmt.Sprintf("/api/%s/scenes", bridge.Username)
+ body, _, err := bridge.Get(uri)
+ if err != nil {
+ return []Scene{}, err
+ }
+
+ fmt.Sprintf("GET SCENES BODY: ", string(body))
+
+ scenes := map[string]Scene{}
+ err = json.Unmarshal(body, &scenes)
+ if err != nil {
+ return []Scene{}, err
+ }
+ scenesList := []Scene{}
+ for key, value := range scenes {
+ scene := Scene{}
+ scene = value
+ scene.ID = key
+ scenesList = append(scenesList, scene)
+ }
+ return scenesList, nil
+}