actions

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2021 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package actions controls hue lights via asynchronous tasks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {

	// The light bulb ids. Empty means the default set of lights. For child
	// actions, the default set of lights is the parent's set of lights;
	// for top-level actions, the default set of lights are the light bulb
	// ids passed to AsTask.
	Lights []int

	// Repeat this many times. 0 or negative means do once.
	Repeat int

	// The Gradient
	G *Gradient

	// The single color
	C gohue.MaybeColor

	// The brightness.
	Bri maybe.Uint8

	// If true, light(s) are turned on. May be used along with G field
	// to ensure light(s) are on.
	On bool

	// If true, light(s) are turned off.
	Off bool

	// Transition time in multiples of 100ms. Nothing means default transition
	// time. See http://developers.meethue.com. Right now it
	// only works with the {C, Bri, On, Off} fields
	TransitionTime maybe.Uint16

	// Sleep sleeps this duration
	Sleep time.Duration

	// Actions to be done in series
	Series []*Action

	// Actions to be done in parallel
	Parallel []*Action
}

Action represents some action to the lights. Callers should set exactly one of the Parallel, Series, G, any subset of {C, Bri, On, Off}, or Sleep fields. The one exception is that On can be used with G. The other fields compliment these fields.

func (*Action) AsTask

func (a *Action) AsTask(setter Setter, lights []int) tasks.Task

AsTask returns a Task from this instance. setter is what changes the lightbulb. lights is the default set of lights empty means all lights. The returned Task does not get its own deep copy of this instance. The results of using it after making further changes to this instance are undefined.

type ColorDuration

type ColorDuration struct {

	// The color the light should be. nothing menas color should be unchanged.
	C gohue.MaybeColor

	// The brightness the light should be. nothing means brightness should be
	// unchanged.
	Bri maybe.Uint8

	// The Duration into the gradient.
	D time.Duration
}

ColorDuration specifies the color and/or brightness a light should have a certain duration into a gradient.

type Gradient

type Gradient struct {

	// The desired color at certain durations into the gradient. The specified
	// durations must be in increasing order.
	Cds []ColorDuration

	// Light color is refreshed this often.
	Refresh time.Duration
}

Gradient represents a change in colors and/or brightness over time.

type NoSuchLightIdError

type NoSuchLightIdError struct {

	// The Unknown light ID
	LightId int

	// The raw response received from the hue bridge
	RawResponse []byte
}

NoSuchLightIdError is the error that Task instances created from Action instances report when a light ID is unknown.

func (*NoSuchLightIdError) Error

func (e *NoSuchLightIdError) Error() string

type Setter

type Setter interface {
	Set(lightId int, properties *gohue.LightProperties) (response []byte, err error)
}

Interface Setter sets the properties of a light. lightId is the ID of the light to set. 0 means all lights.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL