Documentation ¶
Overview ¶
Package controller exposes a generic client to communicate with a single Wiz Bulb
Index ¶
- Constants
- type Error
- type Firmware
- type QueryMessage
- type ResponseChange
- type ResponseStatus
- type ResponseSystem
- type Result
- type State
- type WizController
- func (a *WizController) GetBrightness() int
- func (a *WizController) GetHue() float64
- func (a *WizController) GetOn() bool
- func (a *WizController) GetSaturation() float64
- func (a *WizController) Init() (err error)
- func (a *WizController) Read() (err error)
- func (a *WizController) ReadFirmwareInfo() (err error)
- func (a *WizController) SetBrightness(value int)
- func (a *WizController) SetHue(value float64)
- func (a *WizController) SetOn(value bool)
- func (a *WizController) SetSaturation(value float64)
- func (a *WizController) Write() (err error)
Constants ¶
const METHOD_GET_PILOT = "getPilot"
Get the bulb current state
const METHOD_GET_SYSTEM_CONFIG = "getSystemConfig"
Method to get firmware and other system infos
const METHOD_PULSE = "Pulse"
? - XXX not implemented
const METHOD_REGISTRATION = "Registration"
Register with the bulb to receive heartbeats - XXX not implemented
const METHOD_SET_PILOT = "setPilot"
Set the bulb state
const METHOD_SYNC_PILOT = "syncPilot"
Heartbeats sent by the bulb - XXX not implemented
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Firmware ¶
type Firmware struct { // Mac address, presumably Mac string `json:"mac"` // Not clear what this is, seem to be static HomeId uint `json:"homeId"` // Not clear what this is RoomId uint `json:"roomId"` // Not clear what this is HomeLock bool `json:"homeLock"` // Not clear what this is PairingLock bool `json:"pairingLock"` // Not clear what this is TypeId uint `json:"typeId"` // Firmware info ModuleName string `json:"moduleName"` // Firmware info FwVersion string `json:"fwVersion"` // Not clear what this is GroupId uint `json:"groupId"` // Not clear what this is DrvConf []int `json:"drvConf"` }
Firmware represents system info returned by the bulb
type QueryMessage ¶
type QueryMessage struct { // Method for the messages (see method constants) Method string `json:"method"` // Not sure what is this, defaults to "pro" in all cases Env string `json:"env,omitempty"` // Possibly a unique id for the bulb? Id uint `json:"id,omitempty"` // State to pass to the bulb Params State `json:"params,omitempty"` }
QueryMessage represents a UDP message to be sent to the bulb
type ResponseChange ¶
type ResponseChange struct { Method string `json:"method"` Env string `json:"env,omitempty"` Result Result `json:"result,omitempty"` Error Error `json:"error,omitempty"` }
ReponseChange represents the bulb response to METHOD_SET_PILOT
type ResponseStatus ¶
type ResponseStatus struct { Method string `json:"method"` Env string `json:"env,omitempty"` State State `json:"result,omitempty"` }
ResponseStatus represents the response obtained from the bulb when querying METHOD_GET_PILOT
type ResponseSystem ¶
type ResponseSystem struct { Method string `json:"method"` Env string `json:"env,omitempty"` Result Firmware `json:"result,omitempty"` }
ResponseSystem represents the response obtained from the bulb when querying METHOD_GET_SYSTEM_CONFIG
type Result ¶
type Result struct {
Success bool `json:"success"`
}
In case of success on METHOD_SET_PILOT
type State ¶
type State struct { // XXX unclear what this is Cnx string `json:"cnx,omitempty"` // Bulb mac address? Mac string `json:"mac,omitempty"` // What is this? Received Signal Strength Indicator? Rssi int `json:"rssi,omitempty"` // Doesn't seem to do anything - echoed by the bulb, defaults to udp Src string `json:"src,omitempty"` // Speed - sets the color changing speed in percent - XXX not implemented for now Speed uint `json:"speed,omitempty"` // Temp - sets color temperature in kelvins - XXX not implemented for now Temp uint `json:"temp,omitempty"` // schdPsetId - rhythm id of the room - XXX not implemented for now SchdPsetId uint `json:"schdPsetId,omitempty"` /* sceneId - calls one of the predefined scenes - XXX not implemented for now scene 0 - Red scene 0 - Green scene 0 - Blue scene 0 - Yellow scene 1 - Ocean scene 2 - Romance scene 3 - Sunset scene 4 - Party scene 5 - Fireplace scene 6 - Cozy scene 7 - Forest scene 8 - Pastel Colors scene 9 - Wake-up scene 10 - Bedtime scene 11 - Warm White scene 12 - Day light scene 13 - Cool white scene 14 - Night light scene 15 - Focus scene 16 - Relax scene 17 - True colors scene 18 - TV time scene 19 - Plant growth scene 20 - Spring scene 21 - Summer scene 22 - Fall scene 23 - Deep dive scene 24 - Jungle scene 25 - Mojito scene 26 - Club scene 27 - Christmas scene 28 - Halloween scene 29 - Candlelight scene 30 - Golden white scene 31 - Pulse scene 32 - Steampunk */ // XXX sceneID are problematic - if we repeat them back to the bulb while setting colors, it won't work // Right now, removing the scenes entirely // SceneId uint `json:"sceneId",omitempty` /* State - on or off */ On bool `json:"state"` /* r - red color range 0-255 g - green color range 0-255 b - blue color range 0-255 c - cold white range 0-255 w - warm white range 0-255 */ R uint `json:"r"` G uint `json:"g"` B uint `json:"b"` // XXX not implemented for now C uint `json:"c"` // XXX not implemented for now W uint `json:"w"` /* Bulb dimmer in percent */ Dimming uint `json:"dimming"` }
State represents the current or desired state of the wiz bulb It is being returned by a call to getPilot and should be passed as parameters to setPilot
type WizController ¶
func NewWizController ¶
func NewWizController(address string) *WizController
func (*WizController) GetBrightness ¶
func (a *WizController) GetBrightness() int
Homekit hook to read the bulb brightness
func (*WizController) GetHue ¶
func (a *WizController) GetHue() float64
Homekit hook to read the bulb hue
func (*WizController) GetOn ¶
func (a *WizController) GetOn() bool
Homekit hook to get whether the bulb is on or off
func (*WizController) GetSaturation ¶
func (a *WizController) GetSaturation() float64
Homekit hook to read the bulb saturation
func (*WizController) Init ¶
func (a *WizController) Init() (err error)
Initialize the controller - basically get system info and current state
func (*WizController) Read ¶
func (a *WizController) Read() (err error)
Read the wiz bulb current state
func (*WizController) ReadFirmwareInfo ¶
func (a *WizController) ReadFirmwareInfo() (err error)
Read system and firmware information
func (*WizController) SetBrightness ¶
func (a *WizController) SetBrightness(value int)
Homekit hook to set the bulb brightness
func (*WizController) SetHue ¶
func (a *WizController) SetHue(value float64)
Homekit hook to set the bulb hue
func (*WizController) SetOn ¶
func (a *WizController) SetOn(value bool)
Homekit hook to set the bulb to on or off
func (*WizController) SetSaturation ¶
func (a *WizController) SetSaturation(value float64)
Homekit hook to set the bulb saturation
func (*WizController) Write ¶
func (a *WizController) Write() (err error)
Set the wiz bulb to desired state