aboutsummaryrefslogtreecommitdiff
path: root/light.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-04 14:38:39 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-04 14:38:39 -0500
commita0a8f16f81b36bd700a3d08780ac6e67a9dfc8a0 (patch)
treed989c38f6f8baf004d763413ae0a46e66ed53ed2 /light.go
parentf57f0c6b98ce758756e6c5f2c4aaf8946f5e5cb5 (diff)
Added index to Light struct to easily reference it from []light.
Diffstat (limited to 'light.go')
-rw-r--r--light.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/light.go b/light.go
index 4180c37..0ec8e80 100644
--- a/light.go
+++ b/light.go
@@ -28,6 +28,7 @@ type Light struct {
ManufacturerName string `json:"manufacturername"`
UniqueID string `json:"uniqueid"`
SWVersion string `json:"swversion"`
+ Index int // Set by index of light array response
}
// LightState used in SetLightState to ammend light attributes.
@@ -52,7 +53,7 @@ type LightState struct {
// brightness, and more. See `SetLightState` struct.
func SetLightState(bridge *Bridge, lightID string, newState LightState) error {
uri := fmt.Sprintf("/api/%s/lights/%s/state", bridge.Username, lightID)
- _, _, err := bridge.Post(uri, newState) // TODO: change to PUT
+ _, _, err := bridge.Put(uri, newState) // TODO: change to PUT
if err != nil {
return err
}
@@ -84,6 +85,7 @@ func GetAllLights(bridge *Bridge) ([]Light, error) {
if err != nil {
trace("", err)
}
+ data.Index = index
lights = append(lights, data)
}
return lights, nil