diff options
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 { |