yeelight

package
v0.0.0-...-9a212b9 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Port = "55443"

Port is the default Yeelight port

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	ID     int         `json:"id"`
	Method string      `json:"method"`
	Params interface{} `json:"params"`
}

Command to send to the light

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error struct is used on the ResponseError payload

type Response

type Response struct {
	ID     int         `json:"id"`
	Result interface{} `json:"result,omitempty"`
	Error  Error       `json:"error,omitempty"`
}

Response sent by the light

type Yeelight

type Yeelight struct {
	Location   string   `json:"location"`
	ID         string   `json:"id,omitempty"`
	Model      string   `json:"model,omitempty"`
	FWVersion  int      `json:"fw_ver,omitempty"`
	Support    []string `json:"support,omitempty"`
	Power      string   `json:"power,omitempty"`
	Bright     int      `json:"bright,omitempty"`
	ColorMode  int      `json:"color_mode,omitempty"`
	ColorTemp  int      `json:"ct,omitempty"`
	RGB        int      `json:"rgb,omitempty"`
	Hue        int      `json:"hue,omitempty"`
	Saturation int      `json:"sat,omitempty"`
	Name       string   `json:"name"`
}

Yeelight are the light properties

func Discover

func Discover(timeout time.Duration) ([]Yeelight, error)

Discover uses SSDP to find and return the IP address of the lights credit: https://github.com/edgard/yeelight/blob/master/yeelight.go

func (*Yeelight) CronAdd

func (y *Yeelight) CronAdd(t, value int) (Response, error)

CronAdd method is used to start a timer job on the smart LED.

func (*Yeelight) CronDel

func (y *Yeelight) CronDel(t int) (Response, error)

CronDel method is used to stop the specified cron job.

func (*Yeelight) CronGet

func (y *Yeelight) CronGet(t int) (Response, error)

CronGet method is used to retrieve the setting of the current cron job of the specified type.

func (*Yeelight) GetProp

func (y *Yeelight) GetProp() error

GetProp method is used to retrieve current property a light

func (*Yeelight) Off

func (y *Yeelight) Off() (Response, error)

Off method is used to switch off the smart LED

func (*Yeelight) On

func (y *Yeelight) On() (Response, error)

On method is used to switch on the smart LED

func (*Yeelight) SetAdjust

func (y *Yeelight) SetAdjust(action, prop string) (Response, error)

SetAdjust method is used to change brightness, CT or color of a smart LED without knowing the current value, it's main used by controllers.

func (*Yeelight) SetBright

func (y *Yeelight) SetBright(brightness, duration int) (Response, error)

SetBright method is used to change the brightness of a smart LED.

func (*Yeelight) SetCtAbx

func (y *Yeelight) SetCtAbx(value, duration int) (Response, error)

SetCtAbx method is used to change the color temperature of a smart LED.

func (*Yeelight) SetDefault

func (y *Yeelight) SetDefault() (Response, error)

SetDefault method is used to save current state of smart LED in persistent memory. So if user powers off and then powers on the smart LED again (hard power reset), the smart LED will show last saved state.

func (*Yeelight) SetHSV

func (y *Yeelight) SetHSV(hue, sat, duration int) (Response, error)

SetHSV method is used to change the color of a smart LED.

func (*Yeelight) SetName

func (y *Yeelight) SetName(name string) (Response, error)

SetName method is used to name the device. The name will be stored on the device and reported in discovering response. User can also read the name through “get_prop” method

func (*Yeelight) SetPower

func (y *Yeelight) SetPower(power string, duration int) (Response, error)

SetPower method is used to switch on or off the smart LED (software managed on/off).

func (*Yeelight) SetRGB

func (y *Yeelight) SetRGB(red, green, blue, duration int) (Response, error)

SetRGB method is used to change the color RGB of a smart LED (red, green, blue from 0-255).

func (*Yeelight) SetRGBhex

func (y *Yeelight) SetRGBhex(value, duration int) (Response, error)

SetRGBhex method is used to change the color RGB of a smart LED (using hexadecimal).

func (*Yeelight) SetScene

func (y *Yeelight) SetScene(class, values string) (Response, error)

SetScene method is used to set the smart LED directly to specified state. If the smart LED is off, then it will turn on the smart LED firstly and then apply the specified command.

func (*Yeelight) StartCf

func (y *Yeelight) StartCf(count, action int, flowExpression string) (Response, error)

StartCf method is used to start a color flow. Color flow is a series of smart LED visible state changing. It can be brightness changing, color changing or color temperature changing.This is the most powerful command. All our recommended scenes, e.g. Sunrise/Sunset effect is implemented using this method. With the flow expression, user can actually “program” the light effect.

func (*Yeelight) StopCf

func (y *Yeelight) StopCf() (Response, error)

StopCf method is used to stop a running color flow.

func (*Yeelight) Toggle

func (y *Yeelight) Toggle() (Response, error)

Toggle method is used to toggle the smart LED.

Jump to

Keyboard shortcuts

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