Documentation ¶
Overview ¶
Package lifx provides data structures and functions for communicating with LIFX devices.
This is based on the LAN protocol documented at https://lan.developer.lifx.com/docs, so only supports local (same network) communication.
Index ¶
- Constants
- Variables
- type Client
- type Color
- type Device
- func (d *Device) CaptureState(ctx context.Context) (state State, err error)
- func (d *Device) GetColor(ctx context.Context) (Color, error)
- func (d *Device) GetExtendedColorZones(ctx context.Context) (zones []Color, err error)
- func (d *Device) GetHostFirmware(ctx context.Context) (HostFirmware, error)
- func (d *Device) GetLabel(ctx context.Context) (string, error)
- func (d *Device) GetLightPower(ctx context.Context) (uint16, error)
- func (d *Device) GetPower(ctx context.Context) (uint16, error)
- func (d *Device) GetVersion(ctx context.Context) (vendor, product uint32, err error)
- func (d *Device) QuietOn(ctx context.Context) error
- func (d *Device) RestoreState(ctx context.Context, state State) error
- func (d *Device) SetColor(ctx context.Context, color Color, duration time.Duration) error
- func (d *Device) SetExtendedColorZones(ctx context.Context, duration time.Duration, zones []Color) error
- func (d *Device) SetLightPower(ctx context.Context, level uint16, duration time.Duration) error
- func (d *Device) SetWaveform(ctx context.Context, cfg WaveformConfig) error
- type HostFirmware
- type Product
- type ProductCapabilities
- type State
- type VendorProducts
- type Waveform
- type WaveformConfig
Constants ¶
Variables ¶
var ProductsFile []VendorProducts
ProductsFile represents the data from a products.json file.
The data is decoded from a version of https://github.com/LIFX/products embedded in this package.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { Addr net.UDPAddr Serial [6]byte // Tracef, if set, will be used to write trace lines. Tracef func(ctx context.Context, format string, args ...interface{}) // contains filtered or unexported fields }
Device represents a LIFX device on the local network.
A device is bound to the Client that discovered it.
func (*Device) CaptureState ¶
CaptureState queries the device and returns its current configuration.
func (*Device) GetExtendedColorZones ¶
func (*Device) GetHostFirmware ¶
func (d *Device) GetHostFirmware(ctx context.Context) (HostFirmware, error)
func (*Device) GetVersion ¶
func (*Device) QuietOn ¶
QuietOn turns on the light power if it isn't already turned on. If it wasn't on, the light's brightness will be set to zero first.
func (*Device) RestoreState ¶
RestoreState restores a device to its configuration at the time CaptureState was invoked.
func (*Device) SetExtendedColorZones ¶
func (*Device) SetLightPower ¶
func (*Device) SetWaveform ¶
func (d *Device) SetWaveform(ctx context.Context, cfg WaveformConfig) error
type HostFirmware ¶
type Product ¶
type Product struct { PID uint32 `json:"pid"` Name string `json:"name"` Features ProductCapabilities `json:"features"` Upgrades []struct { Major uint16 `json:"major"` Minor uint16 `json:"minor"` Features ProductCapabilities `json:"features"` } `json:"upgrades"` }
Product represents information about a product.
func DetermineProduct ¶
func DetermineProduct(file []VendorProducts, vendorID, productID uint32, firmwareVersion HostFirmware) (Product, error)
DetermineProduct determines the product and its derived capabilities. Use this rather than manually inspecting ProductsFile, which should be passed as the first argument.
vendorID and productID arguments can be obtained with GetVersion, and firmwareVersion can be obtained with GetHostFirmware.
type ProductCapabilities ¶
type ProductCapabilities struct { HEV *bool `json:"hev,omitempty"` Color *bool `json:"color,omitempty"` Matrix *bool `json:"matrix,omitempty"` Multizone *bool `json:"multizone,omitempty"` TemperatureRange []uint16 `json:"temperature_range"` // should be two values (min and max); may be nil from DetermineProduct ExtendedMultizone *bool `json:"extended_multizone,omitempty"` }
ProductCapabilities represents the functional capabilities of a product.
The fields in this structure are nullable because the data file has a default layering semantic. Any Product returned through DetermineProduct is guaranteed to set all fields, except where otherwise specified.
func (ProductCapabilities) String ¶
func (pc ProductCapabilities) String() string
type VendorProducts ¶
type VendorProducts struct { VID uint32 `json:"vid"` // 1 == LIFX Name string `json:"name"` // e.g. "LIFX" Defaults ProductCapabilities `json:"defaults"` Products []Product `json:"products"` }
VendorProducts represents a vendor and all their products.