bulb

package
v0.0.0-...-ba79be1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bulb

type Bulb struct {
	Addr string
}

Bulb represents all the info necessary to identify a smart light.

func (Bulb) Connect

func (b Bulb) Connect() (*textproto.Conn, error)

Connect initializes a connection to a bulb.

func (Bulb) Send

func (b Bulb) Send(c Command) (resp Response, err error)

Send sends a Command to a bulb and waits for the response.

type Command

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

Command is a a JSON-serializable command in the Yeelight API format.

func NewCommand

func NewCommand(id int, method string, params ...interface{}) Command

NewCommand creates a new Command.

type ParsedResponse

type ParsedResponse struct {
	Id     int      `json:"id"`
	Result []string `json:"result"`
}

ParsedResponse is an already parsed smart light response.

func (ParsedResponse) Success

func (p ParsedResponse) Success() bool

Success indicates whether a Command finished without errors.

type Response

type Response []byte

Response is a raw smart light response to a command.

func (Response) Decode

func (r Response) Decode() (p ParsedResponse, err error)

Decode parses a Response into a ParsedResponse.

Jump to

Keyboard shortcuts

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