diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-02-08 22:24:24 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-02-08 22:24:24 -0500 |
commit | e7deedcd248dbc89623db252dcf2b0559d944abb (patch) | |
tree | 70338f7d49566c64847763857644ff665b377e1e /light.go | |
parent | a05574836d277a8ca3c75ab3a7b7b9a1e1081faa (diff) |
Added ColorLoop on, off, toggle functions.
Diffstat (limited to 'light.go')
-rw-r--r-- | light.go | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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 { |