Documentation
¶
Index ¶
- func Discovery(cidr string) ([]string, error)
- func Listen(ip string) (net.Conn, error)
- type Config
- func (c *Config) AdjustBright(bright, duration int) (Response, error)
- func (c *Config) AdjustColorTemperature(bright, duration int) (Response, error)
- func (c *Config) Close()
- func (c *Config) CronAdd(timer int) (Response, error)
- func (c *Config) CronDelete() (Response, error)
- func (c *Config) CronGet() (Response, error)
- func (c *Config) GenerateRGB(red, green, blue int) int
- func (c *Config) GetProps(p ...interface{}) (Response, error)
- func (c *Config) SetAdjust(action, prop string) (Response, error)
- func (c *Config) SetBright(brightness int, effect string, duration int) (Response, error)
- func (c *Config) SetColorFlow(count, action int, exprs []FlowExpression) (Response, error)
- func (c *Config) SetColorTemp(temp int, effect string, duration int) (Response, error)
- func (c *Config) SetDefault() (Response, error)
- func (c *Config) SetHueSaturation(hue int, sat int, effect string, duration int) (Response, error)
- func (c *Config) SetName(name string) (Response, error)
- func (c *Config) SetPower(power bool, effect string, duration int) (Response, error)
- func (c *Config) SetRGB(red int, green int, blue int, effect string, duration int) (Response, error)
- func (c *Config) SetScene(scene Scene) (Response, error)
- func (c *Config) StopColorFlow() (Response, error)
- type FlowExpression
- type ListenResponse
- type Request
- type Response
- type Scene
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Discovery ¶
This function is used to scan Xiaomi Yeelight device in your Local Area Network with CIDR IP Address.
Types ¶
type Config ¶
func (*Config) AdjustBright ¶
This function is used to adjust the brightness by specified bright percentage within specified duration. "bright" should fill with range -100 ~ 100. "duration" set the action duration with milisecond.
func (*Config) AdjustColorTemperature ¶
This function is used to adjust the color temperature by specified bright percentage within specified duration. "bright" should fill with range -100 ~ 100. "duration" set the action duration with milisecond.
func (*Config) Close ¶
func (c *Config) Close()
After you run the tcp you should close the tcp connection.
func (*Config) CronDelete ¶
This function is used to delete cron job in queue.
func (*Config) GenerateRGB ¶
This function is used to generate RGB to decimal integer to represent the color. You should fill red, green and blue with integer.
func (*Config) GetProps ¶
This function is used to retrieve current property. The allowed values is "power", "bright", "ct", "rgb", "hue", "sat", "color_mode", "flowing", "delayoff", "flow_params", "music_on", "name", "bg_power", "bg_flowing", "bg_flow_params", "bg_ct", "bg_lmode", "bg_bright", "bg_rgb", "bg_hue", "bg_sat", "nl_br", "active_mode"
func (*Config) SetAdjust ¶
This function is used to adjust brightness, color tempterature or color. The allowed value "action" is increase, decrease and circle. The allowed value "prop" is bright, ct and color.
func (*Config) SetBright ¶
This function is used to change the brightness. The allowed value brightness is in range 1 ~ 100. The allowed value effect is "sudden" and "smooth". For the duration action, it's should be more than 30 milliseconds.
func (*Config) SetColorFlow ¶
func (c *Config) SetColorFlow(count, action int, exprs []FlowExpression) (Response, error)
This function is used to start a color flow. "count" is the number of visible state changing before color flow stopped. "action" is the action taken after the flow is stopped. 0 means smart LED recover to the state before the color flow started. 1 means smart LED stay at the state when the flow is stopped. 2 means turn off the smart LED after the flow is stopped.
"exprs" is the expression of the state changing series. Fill with "mode" 1 - color, 2 - color temperature, "duration" for the duration in milliseconds, "value" is following the "mode", color or color temperature.
func (*Config) SetColorTemp ¶
This function is used to change the color temperature. The allowed value for temp is in range 1700 ~ 6500. The allowed value effect is "sudden" and "smooth". For the duration action, it's should be more than 30 milliseconds.
func (*Config) SetDefault ¶
This function is used to save current state.
func (*Config) SetHueSaturation ¶
This function is used to change the color with hue and saturation. The allowed value hue is in range 0 ~ 359. The allowed value sat is in range 0 ~ 100. The allowed value effect is "sudden" and "smooth". For the duration action, it's should be more than 30 milliseconds.
func (*Config) SetName ¶
The function is used to change the device name, stored in device not cloud.
func (*Config) SetPower ¶
This function is used to switch on or off. The allowed value effect is "sudden" and "smooth". For the duration action, it's should be more than 30 milliseconds.
func (*Config) SetRGB ¶
func (c *Config) SetRGB(red int, green int, blue int, effect string, duration int) (Response, error)
This function is used to change the color. The allowed value effect is "sudden" and "smooth". For the duration action, it's should be more than 30 milliseconds.
func (*Config) SetScene ¶
This function is used to set scene with color, hue saturation, color temperature or color flow.
func (*Config) StopColorFlow ¶
The function is used to stop current color flow.
type ListenResponse ¶
type ListenResponse struct { Method string `json:"method"` Params struct { Name string `json:"name"` Power string `json:"power"` ColorTemperature int `json:"ct"` Brightness int `json:"bright"` Flowing int `json:"flowing"` FlowParams string `json:"flow_params"` ColorMode int `json:"color_mode"` Rgb int `json:"rgb"` Hue int `json:"hue"` Saturation int `json:"sat"` DelayOff int `json:"delayoff"` } `json:"params"` }
func ReadMessage ¶
func ReadMessage(conn net.Conn) (ListenResponse, error)
This function is used to read TCP message from function Listen.
Example:
for { _, err := yeelight.ReadMessage(conn) if err != nil { ... } }