Documentation
¶
Overview ¶
Package ops contains building blocks for basic operation of hue lights
Index ¶
- Constants
- func Blink(brights []uint8, magnitude int) []uint8
- func FixError(lightId int, rawResponse []byte, err error) error
- func Restore(ctxt Context, lightColors LightColors) error
- type AtTimeTask
- type ColorBrightness
- type Context
- type HueAction
- type HueTask
- type HueTaskList
- type LightColors
- type LightReader
- type NamedColors
- type StaticHueAction
Constants ¶
const ( // The start of hue task Ids from persistent storage. Hard-coded hue tasks // must have ids less than this. PersistentTaskIdOffset = 10000 )
Variables ¶
This section is empty.
Functions ¶
func Blink ¶
Blink takes a sequence of brightnesses and returns what those brighnesses should be when they blink. brights are the original brighnesses. magnitude is a value between -255 and 255 inclusive that indicates the magnitude of the blink. Positive means lights should blink brighter if possible while negative means lights should blink dimmer if possible.
func FixError ¶
FixError converts a response from gohue.Get() or gohue.Set() into a descriptive error. lightId is the lightId, rawResponse is the response from gohue.Get() or gohue.Set(), err is the original error from gohue.Get() or gohue.Set()
func Restore ¶
func Restore(ctxt Context, lightColors LightColors) error
Restore restores the lights back to their original state. ctxt is the current context; lightColors are the state of the lights as returned by Snapshot.
Types ¶
type AtTimeTask ¶
type AtTimeTask struct { // The schedule Id Id string // The Hue Task H *HueTask // The lights to run on Ls lights.Set // The time to start StartTime time.Time }
AtTimeTask represents a hue task scheduled to run at a particular time on a particular set of lights. These instances must be treated as immutable.
type ColorBrightness ¶
type ColorBrightness struct { Color gohue.MaybeColor Brightness maybe.Uint8 }
ColorBrightness represents a color and brightness.
type Context ¶
type Context interface { // Sets the properties for a particular light Set(lightId int, properties *gohue.LightProperties) ( response []byte, err error) }
Interface Context represents a connection to the hue bridge.
type HueAction ¶
type HueAction interface { // Do does the action. // ctxt is the connection to the hue bridge; lightSet is the exact set of // lights. The tasks package provides e. // If a Do implementation needs more than the Context interface and // ctxt does not implement it then Do does nothing. Do(ctxt Context, lightSet lights.Set, e *tasks.Execution) // UsedLights returns the lights this instance will use given an initial // set of lights. // Implementations of UsedLights must obey these axioms: // 1. UsedLights(UsedLights(A)) == UsedLights(A) // 2. If A subset of B then UsedLights(A) subset of UsedLights(B) UsedLights(lightSet lights.Set) lights.Set }
HueAction represents an action to be done with hue lights.
type HueTask ¶
HueTask represents a HueAction with an ID and description. These instances must be treated as immutable.
func (*HueTask) GetDescription ¶
GetDescription returns the description of this instance.
type HueTaskList ¶
type HueTaskList []*HueTask
HueTaskList represents an immutable list of hue tasks.
type LightColors ¶
type LightColors map[int]ColorBrightness
LightColors represents both color and brightness for each light. The key of the map is the light id; the value is the color and brightness for that light. A color and brightness for light id 0 means all lights are to have that color and brightness. These instances must be treated as immutable.
func Snapshot ¶
func Snapshot(reader LightReader, lightSet lights.Set) (LightColors, error)
Snapshot reads the current state of the lights in lightSet.
type LightReader ¶
type LightReader interface {
Get(lightId int) (*gohue.LightProperties, []byte, error)
}
Interface LightReader reads the state of a light
type NamedColors ¶
type NamedColors struct { Id int64 Colors LightColors Description string }
NamedColors represents colors for lights by name read from persistent storage.
func (*NamedColors) AsHueTask ¶
func (nc *NamedColors) AsHueTask() *HueTask
AsHueTask converts this instance to a HueTask
type StaticHueAction ¶
type StaticHueAction LightColors
StaticHueAction represents a HueAction that turns each light on to some some color and brightness. These instances must be treated as immutable.
func (StaticHueAction) UsedLights ¶
func (a StaticHueAction) UsedLights(lightSet lights.Set) lights.Set