aboutsummaryrefslogtreecommitdiff
path: root/light.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-07 17:42:26 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-07 17:42:26 -0500
commit7df767996b0b8d7daab32cf43585a97437261df8 (patch)
tree08720b9b60f216ffe2b2a6f2001e618e773f536d /light.go
parentd3c0bdfa560e4200ed9c4ff4b80dec491afc0e5c (diff)
Added light.Toggle func and documentation for On, Off, Toggle.
Diffstat (limited to 'light.go')
-rw-r--r--light.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/light.go b/light.go
index 2672171..d1908e2 100644
--- a/light.go
+++ b/light.go
@@ -50,15 +50,25 @@ type LightState struct {
XYIncrement *[2]float32 `json:"xy_inc,omitempty"`
}
+// light.TurnOff will change the light state to the "Off" mode.
func (self *Light) TurnOff() {
SetLightState(self, LightState{On: false})
}
+// light.TurnOn will change the light state to the "On" mode.
func (self *Light) TurnOn() {
SetLightState(self, LightState{On: true})
}
-
+// light.Toggle will change the light state to "On" if
+// the light is off or "Off" if the light is on.
+func (self *Light) Toggle() {
+ if self.State.On {
+ self.TurnOff()
+ } else {
+ self.TurnOn()
+ }
+}
// SetLightState will modify light attributes such as on/off, saturation,
// brightness, and more. See `SetLightState` struct.