keylight

package module
v0.0.0-...-a45c372 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 6 Imported by: 9 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

keylight-go

A Go library for interacting with Elgato/Corsair Key Lights.

It is known to support both the Elgato KeyLight and the Elgato KeyLight Air's, but it has not been tested with the new Ring Light.

Usage

see examples/flash for an example of using the library to discover and control lights.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Name    string
	DNSAddr string
	Port    int
}

Device represents an actual KeyLight. They can be found using a Discovery interface, or created with a given DNSAddr and Port when running in a static environment.

func (*Device) FetchDeviceInfo

func (k *Device) FetchDeviceInfo(ctx context.Context) (*DeviceInfo, error)

FetchDeviceInfo returns metadata for the accessory.

func (*Device) FetchLightGroup

func (k *Device) FetchLightGroup(ctx context.Context) (*LightGroup, error)

FetchLightGroup returns all of the individual lights that are owned by an accessory. This in conjunction with UpdateLightGroup will allow you to control your lights.

func (*Device) FetchSettings

func (k *Device) FetchSettings(ctx context.Context) (*DeviceSettings, error)

FetchSettings allows you to retrieve general device settings.

func (*Device) UpdateLightGroup

func (k *Device) UpdateLightGroup(ctx context.Context, newOptions *LightGroup) (*LightGroup, error)

UpdateLightGroup allows you to update the settings for individual lights in an accessory. It returns the updated options.

type DeviceInfo

type DeviceInfo struct {
	ProductName         string   `json:"productName"`
	HardwareBoardType   int      `json:"hardwareBoardType"`
	FirmwareBuildNumber int      `json:"firmwareBuildNumber"`
	FirmwareVersion     string   `json:"firmwareVersion"`
	SerialNumber        string   `json:"serialNumber"`
	DisplayName         string   `json:"displayName"`
	Features            []string `json:"features"`
}

DeviceInfo returns read-only information about a given Elgato device. This is currently only supported by keylight devices but as other devices may expose _elg.tcp services, it may also be suppported by other products in the future.

type DeviceSettings

type DeviceSettings struct {
	PowerOnBehavior       int `json:"powerOnBehavior"`
	PowerOnBrightness     int `json:"powerOnBrightness"`
	PowerOnTemperature    int `json:"powerOnTemperature"`
	SwitchOnDurationMs    int `json:"switchOnDurationMs"`
	SwitchOffDurationMs   int `json:"switchOffDurationMs"`
	ColorChangeDurationMs int `json:"colorChangeDurationMs"`
}

DeviceSettings represents the data returned and accepted by a KeyLight for configuring its behaviour.

type Discovery

type Discovery interface {
	// Run will start the given discovery client and run syncronously until the
	// provided context is shutdown.
	Run(ctx context.Context) error

	// ResultsCh returns a channel of discovered Key Lights.
	// NOTE: It currently does not filter the results so may return non key light
	//       entities if they expose the `_elg._tcp` service over mdns.
	//       Use KeyLight.FetchDeviceInfo(...) to determine the accessory info
	//       if you run into problems.
	ResultsCh() <-chan *Device
}

Discovery is the interface that is exposed to discover KeyLight devices. The default implementation discovers lights via Bonjour.

func NewDiscovery

func NewDiscovery() (Discovery, error)

NewDiscovery returns a new default Disocvery implemetnation. This is currently backed by Bonjour.

type Light

type Light struct {
	On          int `json:"on"`
	Brightness  int `json:"brightness"`
	Temperature int `json:"temperature"`
}

Light is the struct that encapsulates the state of a KeyLight's individual light. Most keylight devices currently only have one 'Light'.

func (*Light) Copy

func (l *Light) Copy() *Light

Copy returns a new copy of a light.

type LightGroup

type LightGroup struct {
	Count  int      `json:"numberOfLights"`
	Lights []*Light `json:"lights"`
}

LightGroup represents a set of configurable lights within a given KeyLight device.

func (*LightGroup) Copy

func (o *LightGroup) Copy() *LightGroup

Copy returns a new deep copy of a LightGroup.

Directories

Path Synopsis
examples
flash command

Jump to

Keyboard shortcuts

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