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
- type Device
- func (d *Device) CachedGroup() string
- func (d *Device) CachedHardwareProduct() uint32
- func (d *Device) CachedHardwareVendor() uint32
- func (d *Device) CachedHardwareVersion() uint32
- func (d *Device) CachedLabel() string
- func (d *Device) CachedLocation() string
- func (d *Device) CachedPower() bool
- func (d *Device) Close() error
- func (d *Device) CloseSubscription(sub *common.Subscription) error
- func (d *Device) Discover() error
- func (d *Device) GetAddress() *net.UDPAddr
- func (d *Device) GetGroup() (ret string, err error)
- func (d *Device) GetHardwareProduct() (uint32, error)
- func (d *Device) GetHardwareVendor() (uint32, error)
- func (d *Device) GetHardwareVersion() (uint32, error)
- func (d *Device) GetLabel() (string, error)
- func (d *Device) GetLocation() (ret string, err error)
- func (d *Device) GetPower() (bool, error)
- func (d *Device) Handle(pkt *packet.Packet)
- func (d *Device) ID() uint64
- func (d *Device) NewSubscription() (*common.Subscription, error)
- func (d *Device) ResetLimiter()
- func (d *Device) Seen() time.Time
- func (d *Device) Send(pkt *packet.Packet, ackRequired, responseRequired bool) (packet.Chan, error)
- func (d *Device) SetLabel(label string) error
- func (d *Device) SetPower(state bool) error
- func (d *Device) SetSeen(seen time.Time)
- func (d *Device) SetStateGroup(pkt *packet.Packet) error
- func (d *Device) SetStateLabel(pkt *packet.Packet) error
- func (d *Device) SetStateLocation(pkt *packet.Packet) error
- func (d *Device) SetStatePower(pkt *packet.Packet) error
- type GenericDevice
- type Group
- func (g *Group) AddDevice(dev GenericDevice) error
- func (g *Group) CachedColor() common.Color
- func (g *Group) CachedPower() bool
- func (g *Group) Close() error
- func (g *Group) CloseSubscription(sub *common.Subscription) error
- func (g *Group) Devices() (devices []common.Device)
- func (g *Group) GetColor() (common.Color, error)
- func (g *Group) GetLabel() string
- func (g *Group) GetPower() (bool, error)
- func (g *Group) ID() string
- func (g *Group) Lights() []common.Light
- func (g *Group) NewSubscription() (*common.Subscription, error)
- func (g *Group) Parse(pkt *packet.Packet) error
- func (g *Group) RemoveDevice(dev GenericDevice) error
- func (g *Group) SetColor(color common.Color, duration time.Duration) error
- func (g *Group) SetPower(state bool) error
- func (g *Group) SetPowerDuration(state bool, duration time.Duration) error
- type Light
- func (l *Light) CachedColor() common.Color
- func (l *Light) Get() error
- func (l *Light) GetColor() (common.Color, error)
- func (l *Light) SetColor(color common.Color, duration time.Duration) error
- func (l *Light) SetPowerDuration(state bool, duration time.Duration) error
- func (l *Light) SetState(pkt *packet.Packet) error
- type Location
Constants ¶
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 VendorLifx = 1 ProductLifxOriginal1000 uint32 = 1 ProductLifxColor650 uint32 = 3 ProductLifxWhite800LowVoltage uint32 = 10 ProductLifxWhite800HighVoltage uint32 = 11 ProductLifxWhite900BR30 uint32 = 18 ProductLifxColor1000BR30 uint32 = 20 ProductLifxColor1000 uint32 = 22 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
func (*Device) CachedGroup ¶ added in v0.3.4
func (*Device) CachedHardwareProduct ¶ added in v0.4.0
func (*Device) CachedHardwareVendor ¶ added in v0.4.0
func (*Device) CachedHardwareVersion ¶ added in v0.4.0
func (*Device) CachedLabel ¶ added in v0.4.0
func (*Device) CachedLocation ¶ added in v0.3.4
func (*Device) CachedPower ¶ added in v0.3.0
func (*Device) CloseSubscription ¶ added in v0.1.0
func (d *Device) CloseSubscription(sub *common.Subscription) error
CloseSubscription is a callback for handling the closing of subscriptions.
func (*Device) GetAddress ¶
func (*Device) GetHardwareProduct ¶
func (*Device) GetHardwareVendor ¶
func (*Device) GetHardwareVersion ¶
func (*Device) GetLocation ¶ added in v0.2.0
func (*Device) NewSubscription ¶ added in v0.1.0
func (d *Device) NewSubscription() (*common.Subscription, error)
NewSubscription returns a new *common.Subscription for receiving events from this device.
func (*Device) ResetLimiter ¶
func (d *Device) ResetLimiter()
func (*Device) SetStateGroup ¶ added in v0.2.0
func (*Device) SetStateLocation ¶ added in v0.2.0
type GenericDevice ¶
type GenericDevice interface { common.Device Handle(*packet.Packet) Close() error Seen() time.Time SetSeen(time.Time) SetStatePower(*packet.Packet) error SetStateLabel(*packet.Packet) error SetStateLocation(*packet.Packet) error SetStateGroup(*packet.Packet) error GetLocation() (string, error) GetGroup() (string, error) GetHardwareVendor() (uint32, error) GetHardwareProduct() (uint32, error) ResetLimiter() }
type Group ¶ added in v0.2.0
func (*Group) AddDevice ¶ added in v0.2.0
func (g *Group) AddDevice(dev GenericDevice) error
func (*Group) CachedColor ¶ added in v0.3.0
func (*Group) CachedPower ¶ added in v0.3.0
func (*Group) CloseSubscription ¶ added in v0.2.0
func (g *Group) CloseSubscription(sub *common.Subscription) error
CloseSubscription is a callback for handling the closing of subscriptions.
func (*Group) GetColor ¶ added in v0.2.0
GetColor returns the average color for lights in the group, or error if any light returns an error.
I doubt this is accurate as color theory, but it's good enough for this use-case.
func (*Group) NewSubscription ¶ added in v0.2.0
func (g *Group) NewSubscription() (*common.Subscription, error)
NewSubscription returns a new *common.Subscription for receiving events from this group.
func (*Group) RemoveDevice ¶ added in v0.2.0
func (g *Group) RemoveDevice(dev GenericDevice) error
type Light ¶
type Light struct { *Device // contains filtered or unexported fields }