diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-02-04 23:52:11 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-02-04 23:52:11 -0500 |
commit | 666b312e0011459f471f89257c5dd8e3e495ee95 (patch) | |
tree | 578c4fa1b6cfb9edebb1ad3753bea07913c533c7 /light.go | |
parent | a0a8f16f81b36bd700a3d08780ac6e67a9dfc8a0 (diff) |
Added json bindings for LightState struct.
Diffstat (limited to 'light.go')
-rw-r--r-- | light.go | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -28,31 +28,31 @@ type Light struct { ManufacturerName string `json:"manufacturername"` UniqueID string `json:"uniqueid"` SWVersion string `json:"swversion"` - Index int // Set by index of light array response + Index int // Set by index of light array response // TODO: change to smaller int } // LightState used in SetLightState to ammend light attributes. type LightState struct { - On bool - Bri uint8 - Hue uint16 - Sat uint8 - XY [2]float32 - CT uint16 - Alert string - Effect string - TransitionTime string - BrightnessIncrement int // TODO: -254 to 254 - SaturationIncrement int // TODO: -254 to 254 - HueIncrement int // TODO: -65534 to 65534 - CTIncrement int // TODO: -65534 to 65534 - XYIncrement [2]float32 + On bool `json:"on,omitempty"` + Bri uint8 `json:"bri,omitempty"` + Hue uint16 `json:"hue,omitempty"` + Sat uint8 `json:"sat,omitempty"` + XY [2]float32 `json:"xy,omitempty"` + CT uint16 `json:"ct,omitempty"` + Alert string `json:"alert,omitempty"` + Effect string `json:"effect,omitempty"` + TransitionTime string `json:"transitiontime,omitempty"` + BrightnessIncrement int `json:"bri_inc,omitempty"` // TODO: -254 to 254 + SaturationIncrement int `json:"sat_inc,omitempty"` // TODO: -254 to 254 + HueIncrement int `json:"hue_inc,omitempty"` // TODO: -65534 to 65534 + CTIncrement int `json:"ct_inc,omitempty"` // TODO: -65534 to 65534 + XYIncrement [2]float32 `json:"xy_inc,omitempty"` } // SetLightState will modify light attributes such as on/off, saturation, // 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) +func SetLightState(bridge *Bridge, index int, newState LightState) error { + uri := fmt.Sprintf("/api/%s/lights/%d/state", bridge.Username, index) _, _, err := bridge.Put(uri, newState) // TODO: change to PUT if err != nil { return err |