device

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package device implements a LIFX LAN protocol version 2 device.

This package is not designed to be accessed by end users, all interaction should occur via the Client in the golifx package.

Index

Constants

View Source
const (
	GetService        shared.Message = 2
	StateService      shared.Message = 3
	GetHostInfo       shared.Message = 12
	StateHostInfo     shared.Message = 13
	GetHostFirmware   shared.Message = 14
	StateHostFirmware shared.Message = 15
	GetWifiInfo       shared.Message = 16
	StateWifiInfo     shared.Message = 17
	GetWifiFirmware   shared.Message = 18
	StateWifiFirmware shared.Message = 19
	GetPower          shared.Message = 20
	SetPower          shared.Message = 21
	StatePower        shared.Message = 22
	GetLabel          shared.Message = 23
	SetLabel          shared.Message = 24
	StateLabel        shared.Message = 25
	GetVersion        shared.Message = 32
	StateVersion      shared.Message = 33
	GetInfo           shared.Message = 34
	StateInfo         shared.Message = 35
	Acknowledgement   shared.Message = 45
	GetLocation       shared.Message = 48
	StateLocation     shared.Message = 50
	GetGroup          shared.Message = 51
	StateGroup        shared.Message = 53
	EchoRequest       shared.Message = 58
	EchoResponse      shared.Message = 59
)
View Source
const (
	Get             shared.Message = 101
	SetColor        shared.Message = 102
	State           shared.Message = 107
	LightGetPower   shared.Message = 116
	LightSetPower   shared.Message = 117
	LightStatePower shared.Message = 118
)

Variables

View Source
var (
	// Vendors automatically generated from products.json
	Vendors = map[uint32]Vendor{
		1: Vendor{
			ID:   1,
			Name: `LIFX`,
			Products: map[uint32]*Product{
				1:  &Product{ID: 1, VendorID: 1, Name: `Original 1000`, Features: 2},
				3:  &Product{ID: 3, VendorID: 1, Name: `Color 650`, Features: 2},
				10: &Product{ID: 10, VendorID: 1, Name: `White 800 (Low Voltage)`, Features: 0},
				11: &Product{ID: 11, VendorID: 1, Name: `White 800 (High Voltage)`, Features: 0},
				18: &Product{ID: 18, VendorID: 1, Name: `White 900 BR30 (Low Voltage)`, Features: 0},
				20: &Product{ID: 20, VendorID: 1, Name: `Color 1000 BR30`, Features: 2},
				22: &Product{ID: 22, VendorID: 1, Name: `Color 1000`, Features: 2},
				27: &Product{ID: 27, VendorID: 1, Name: `LIFX A19`, Features: 2},
				28: &Product{ID: 28, VendorID: 1, Name: `LIFX BR30`, Features: 2},
				29: &Product{ID: 29, VendorID: 1, Name: `LIFX+ A19`, Features: 6},
				30: &Product{ID: 30, VendorID: 1, Name: `LIFX+ BR30`, Features: 6},
				31: &Product{ID: 31, VendorID: 1, Name: `LIFX Z`, Features: 6},
				36: &Product{ID: 36, VendorID: 1, Name: `LIFX Downlight`, Features: 2},
				37: &Product{ID: 37, VendorID: 1, Name: `LIFX Downlight`, Features: 2},
				43: &Product{ID: 43, VendorID: 1, Name: `LIFX A19`, Features: 2},
				44: &Product{ID: 44, VendorID: 1, Name: `LIFX BR30`, Features: 2},
				45: &Product{ID: 45, VendorID: 1, Name: `LIFX+ A19`, Features: 6},
				46: &Product{ID: 46, VendorID: 1, Name: `LIFX+ BR30`, Features: 6},
			},
		},
	}
)

Functions

This section is empty.

Types

type Device

type Device struct {
	common.SubscriptionProvider
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(addr *net.UDPAddr, requestSocket *net.UDPConn, timeout *time.Duration, retryInterval *time.Duration, reliable bool, pkt *packet.Packet) (*Device, error)

func (*Device) CachedFirmwareVersion added in v0.4.1

func (d *Device) CachedFirmwareVersion() string

func (*Device) CachedGroup added in v0.3.4

func (d *Device) CachedGroup() string

func (*Device) CachedHardwareProduct added in v0.4.0

func (d *Device) CachedHardwareProduct() uint32

func (*Device) CachedHardwareVendor added in v0.4.0

func (d *Device) CachedHardwareVendor() uint32

func (*Device) CachedHardwareVersion added in v0.4.0

func (d *Device) CachedHardwareVersion() uint32

func (*Device) CachedLabel added in v0.4.0

func (d *Device) CachedLabel() string

func (*Device) CachedLocation added in v0.3.4

func (d *Device) CachedLocation() string

func (*Device) CachedPower added in v0.3.0

func (d *Device) CachedPower() bool

func (*Device) CachedProduct added in v1.0.0

func (d *Device) CachedProduct() *Product

func (*Device) Close

func (d *Device) Close() error

Close cleans up Device resources

func (*Device) Discover

func (d *Device) Discover() error

func (*Device) GetAddress

func (d *Device) GetAddress() *net.UDPAddr

func (*Device) GetFirmwareVersion added in v0.4.1

func (d *Device) GetFirmwareVersion() (ret string, err error)

func (*Device) GetGroup added in v0.2.0

func (d *Device) GetGroup() (ret string, err error)

func (*Device) GetHardwareProduct

func (d *Device) GetHardwareProduct() (uint32, error)

func (*Device) GetHardwareVendor

func (d *Device) GetHardwareVendor() (uint32, error)

func (*Device) GetHardwareVersion

func (d *Device) GetHardwareVersion() (uint32, error)

func (*Device) GetLabel

func (d *Device) GetLabel() (string, error)

func (*Device) GetLocation added in v0.2.0

func (d *Device) GetLocation() (ret string, err error)

func (*Device) GetPower

func (d *Device) GetPower() (bool, error)

func (*Device) GetProduct added in v1.0.0

func (d *Device) GetProduct() (*Product, error)

func (*Device) GetProductName added in v1.0.0

func (d *Device) GetProductName() (string, error)

func (*Device) Handle

func (d *Device) Handle(pkt *packet.Packet)

func (*Device) ID

func (d *Device) ID() uint64

func (*Device) Provisional added in v0.4.1

func (d *Device) Provisional() bool

func (*Device) ResetLimiter

func (d *Device) ResetLimiter()

func (*Device) Seen

func (d *Device) Seen() time.Time

func (*Device) Send

func (d *Device) Send(pkt *packet.Packet, ackRequired, responseRequired bool) (packet.Chan, error)

func (*Device) SetLabel

func (d *Device) SetLabel(label string) error

func (*Device) SetPower

func (d *Device) SetPower(state bool) error

func (*Device) SetProvisional added in v0.4.1

func (d *Device) SetProvisional(provisional bool)

func (*Device) SetSeen

func (d *Device) SetSeen(seen time.Time)

func (*Device) SetStateGroup added in v0.2.0

func (d *Device) SetStateGroup(pkt *packet.Packet) error

func (*Device) SetStateHostFirmware added in v0.4.1

func (d *Device) SetStateHostFirmware(pkt *packet.Packet) error

func (*Device) SetStateLabel

func (d *Device) SetStateLabel(pkt *packet.Packet) error

func (*Device) SetStateLocation added in v0.2.0

func (d *Device) SetStateLocation(pkt *packet.Packet) error

func (*Device) SetStatePower

func (d *Device) SetStatePower(pkt *packet.Packet) error

type Feature added in v1.0.0

type Feature uint32

Feature flags for devices

const (
	FeatureLight Feature = iota << 1
	FeatureColor
	FeatureInfrared
	FeatureMultizone
)

func FeatureString added in v1.0.0

func FeatureString(s string) (Feature, error)

func (Feature) String added in v1.0.0

func (i Feature) String() string

type GenericDevice

type GenericDevice interface {
	common.Device
	Handle(*packet.Packet)
	Close() error
	Seen() time.Time
	SetSeen(time.Time)
	Provisional() bool
	SetProvisional(bool)
	SetStatePower(*packet.Packet) error
	SetStateLabel(*packet.Packet) error
	SetStateLocation(*packet.Packet) error
	SetStateGroup(*packet.Packet) error
	GetLocation() (string, error)
	CachedLocation() string
	GetGroup() (string, error)
	CachedGroup() string
	GetProduct() (*Product, error)
	ResetLimiter()
}

type Group added in v0.2.0

type Group struct {
	common.SubscriptionProvider
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewGroup added in v0.2.0

func NewGroup(pkt *packet.Packet) (*Group, error)

func (*Group) AddDevice added in v0.2.0

func (g *Group) AddDevice(dev GenericDevice) error

func (*Group) CachedColor added in v0.3.0

func (g *Group) CachedColor() common.Color

func (*Group) CachedPower added in v0.3.0

func (g *Group) CachedPower() bool

func (*Group) Close added in v0.2.0

func (g *Group) Close() error

Close cleans up Group resources

func (*Group) Devices added in v0.2.0

func (g *Group) Devices() (devices []common.Device)

func (*Group) GetColor added in v0.2.0

func (g *Group) GetColor() (common.Color, error)

func (*Group) GetLabel added in v0.2.0

func (g *Group) GetLabel() string

func (*Group) GetPower added in v0.2.0

func (g *Group) GetPower() (bool, error)

func (*Group) ID added in v0.2.0

func (g *Group) ID() string

func (*Group) Lights added in v0.2.0

func (g *Group) Lights() []common.Light

func (*Group) Parse added in v0.2.0

func (g *Group) Parse(pkt *packet.Packet) error

func (*Group) RemoveDevice added in v0.2.0

func (g *Group) RemoveDevice(dev GenericDevice) error

func (*Group) SetColor added in v0.2.0

func (g *Group) SetColor(color common.Color, duration time.Duration) error

func (*Group) SetPower added in v0.2.0

func (g *Group) SetPower(state bool) error

func (*Group) SetPowerDuration added in v0.2.0

func (g *Group) SetPowerDuration(state bool, duration time.Duration) error

type Light

type Light struct {
	*Device
	// contains filtered or unexported fields
}

func (*Light) CachedColor added in v0.3.0

func (l *Light) CachedColor() common.Color

func (*Light) Get

func (l *Light) Get() error

func (*Light) GetColor

func (l *Light) GetColor() (common.Color, error)

func (*Light) SetColor

func (l *Light) SetColor(color common.Color, duration time.Duration) error

func (*Light) SetPowerDuration

func (l *Light) SetPowerDuration(state bool, duration time.Duration) error

func (*Light) SetState

func (l *Light) SetState(pkt *packet.Packet) error

type Location added in v0.2.0

type Location struct {
	// Location is a Group
	Group
}

func NewLocation added in v0.2.0

func NewLocation(pkt *packet.Packet) (*Location, error)

type Product added in v1.0.0

type Product struct {
	ID       uint32
	VendorID uint32
	Name     string
	Features Feature
}

func (*Product) Supports added in v1.0.0

func (p *Product) Supports(feature Feature) bool

func (*Product) UnmarshalJSON added in v1.0.0

func (p *Product) UnmarshalJSON(b []byte) error

type Vendor added in v1.0.0

type Vendor struct {
	ID       uint32
	Name     string
	Products map[uint32]*Product
}

func (*Vendor) UnmarshalJSON added in v1.0.0

func (v *Vendor) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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