aboutsummaryrefslogtreecommitdiff
path: root/light.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-08 22:24:24 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-08 22:24:24 -0500
commite7deedcd248dbc89623db252dcf2b0559d944abb (patch)
tree70338f7d49566c64847763857644ff665b377e1e /light.go
parenta05574836d277a8ca3c75ab3a7b7b9a1e1081faa (diff)
Added ColorLoop on, off, toggle functions.
Diffstat (limited to 'light.go')
-rw-r--r--light.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/light.go b/light.go
index 8ad16f4..b62fec4 100644
--- a/light.go
+++ b/light.go
@@ -9,6 +9,7 @@ import (
"errors"
)
+// Light struct defines attributes of a light.
type Light struct {
State struct {
On bool `json:"on"` // On or Off state of the light ("true" or "false")
@@ -32,7 +33,7 @@ type Light struct {
Bridge *Bridge
}
-// LightState used in SetLightState to ammend light attributes.
+// LightState used in SetLightState to amend light attributes.
type LightState struct {
On bool `json:"on"`
Bri uint8 `json:"bri,omitempty"`
@@ -69,6 +70,22 @@ func (self *Light) Toggle() {
}
}
+func (self *Light) ColorLoopOn() error {
+ return SetLightState(self, LightState{On: true, Effect: "colorloop"})
+}
+
+func (self *Light) ColorLoopOff() error {
+ return SetLightState(self, LightState{On: true, Effect: "none"})
+}
+
+func (self *Light) ColorLoop() error {
+ if self.State.Effect == "colorloop" {
+ return self.ColorLoopOff()
+ } else {
+ return self.ColorLoopOn()
+ }
+}
+
// SetLightState will modify light attributes such as on/off, saturation,
// brightness, and more. See `SetLightState` struct.
func SetLightState(light *Light, newState LightState) error {