aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--scene.go15
-rw-r--r--scene_test.go3
3 files changed, 20 insertions, 2 deletions
diff --git a/README.md b/README.md
index 7ba8494..748992e 100644
--- a/README.md
+++ b/README.md
@@ -50,12 +50,12 @@ Pull requests happily accepted on GitHub
- [ ] Delete schedule
##### Scenes
-- [ ] Get all scenes
+- [x] Get all scenes
+- [x] Get scene by ID
- [ ] Create scene
- [ ] Modify scene
- [ ] Recall scene
- [ ] Delete scene
-- [ ] Get scene
##### Sensors
- [ ] Get all sensors
diff --git a/scene.go b/scene.go
index fdc4fcd..95fac29 100644
--- a/scene.go
+++ b/scene.go
@@ -52,3 +52,18 @@ func (bridge *Bridge) GetScenes() ([]Scene, error) {
}
return scenesList, nil
}
+
+func (bridge *Bridge) GetScene(id string) (Scene, error) {
+ uri := fmt.Sprintf("/api/%s/scenes/%s", bridge.Username, id)
+ body, _, err := bridge.Get(uri)
+ if err != nil {
+ return Scene{}, err
+ }
+
+ scene := Scene{}
+ err = json.Unmarshal(body, &scene)
+ if err != nil {
+ return Scene{}, err
+ }
+ return scene, nil
+}
diff --git a/scene_test.go b/scene_test.go
index 82646d6..27998f6 100644
--- a/scene_test.go
+++ b/scene_test.go
@@ -18,4 +18,7 @@ func TestGetScenes(t *testing.T) {
for scene := range scenes {
fmt.Println("SCENE: ", scenes[scene])
}
+
+ individual, _ := bridge.GetScene(scenes[0].ID)
+ fmt.Println("Individual scene: ", individual)
}