aboutsummaryrefslogtreecommitdiff
path: root/scene.go
diff options
context:
space:
mode:
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
+}