aboutsummaryrefslogtreecommitdiff
path: root/light.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-01-31 10:42:12 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-01-31 10:42:12 -0500
commitcd035e828c499dd354e6c4cc1de676af0b47610a (patch)
tree30c03e49e653c008a2eb13b824cc5492396b5dda /light.go
parent4aa25095974a5369ac9319bd613c97ec73d7f5b1 (diff)
Fixed json unmarshal issue in GetAllLights caused by invalid data type (was not []float).
Diffstat (limited to 'light.go')
-rw-r--r--light.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/light.go b/light.go
index f51a031..da137f2 100644
--- a/light.go
+++ b/light.go
@@ -4,7 +4,6 @@ package hue
import (
"fmt"
- "os"
"net/http"
"io/ioutil"
"encoding/json"
@@ -18,8 +17,8 @@ type Light struct {
Bri int `json:"bri"` // Brightness value 1-254
Hue int `json:"hue"` // Hue value 1-65535
Saturation int `json:"sat"` // Saturation value 0-254
- Effect string `json:"effect"` //
- XY []string `json:"xy"` // Coordinates of color in CIE color space
+ Effect string `json:"effect"`
+ XY [2]float32 `json:"xy"` // Coordinates of color in CIE color space
CT int `json:"ct"` // Mired Color Temperature (google it)
Alert string `json:"alert"`
ColorMode string `json:"colormode"`
@@ -69,10 +68,8 @@ func GetAllLights(bridge *Bridge) []Light {
fmt.Sprintf("http://%s/api/%s/lights/%d", bridge.IPAddress, bridge.Username, index))
if err != nil {
trace("", err)
- os.Exit(1)
} else if response.StatusCode != 200 {
trace(fmt.Sprintf("Bridge status error %d", response.StatusCode), nil)
- os.Exit(1)
}
// Read the response
@@ -80,7 +77,6 @@ func GetAllLights(bridge *Bridge) []Light {
defer response.Body.Close()
if err != nil {
trace("", err)
- os.Exit(1)
}
if strings.Contains(string(body), "not available") {
// Handle end of searchable lights