diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | scene.go | 15 | ||||
-rw-r--r-- | scene_test.go | 3 |
3 files changed, 20 insertions, 2 deletions
@@ -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 @@ -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) } |