Documentation ¶
Index ¶
- func SortMapStringSlice(m map[string][]string) map[string][]string
- type Broadlink
- func (b *Broadlink) AddManualDevice(ip string, macs string, deviceType int) error
- func (b Broadlink) Count() int
- func (b Broadlink) DeviceExists(id string) bool
- func (b Broadlink) DeviceIds() map[string][]string
- func (b Broadlink) DeviceTypes() map[int]string
- func (b *Broadlink) Discover() error
- func (b *Broadlink) DiscoverHost(host string) error
- func (b *Broadlink) Execute(id, s string) error
- func (b *Broadlink) GetPowerState(id string) (bool, error)
- func (b *Broadlink) Learn(id string) (string, error)
- func (b *Broadlink) LearnRF(id string) (string, error)
- func (b *Broadlink) RemoveDevice(key string)
- func (b *Broadlink) WithTimeout(t int) *Broadlink
- type Response
- type ResponseType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Broadlink ¶
type Broadlink struct {
// contains filtered or unexported fields
}
Broadlink keeps a track of all the devices and sockets.
func NewBroadlink ¶
func NewBroadlink() Broadlink
NewBroadlink creates and initializes a new Broadlink struct.
func (*Broadlink) AddManualDevice ¶
func (Broadlink) DeviceExists ¶
func (Broadlink) DeviceTypes ¶
func (*Broadlink) DiscoverHost ¶
Discover will populate the Broadlink struct with a device.
func (*Broadlink) Execute ¶
Execute looks at the device type and decides if it should call send() or setPowerState().
func (*Broadlink) GetPowerState ¶
GetPowerState queries a WiFi-enabled power outlet and returns its state (on or off).
func (*Broadlink) Learn ¶
Learn sends a learn command to the specified device. If id is an empty string it selects the first device.
func (*Broadlink) LearnRF ¶
LearnRF sends an RF Sweep command to the specified device. If id is an empty string it selects the first device.
func (*Broadlink) RemoveDevice ¶
func (*Broadlink) WithTimeout ¶
WithTimeout sets the timeout for all subsequent read operations.
type Response ¶
type Response struct { Type ResponseType Data []byte }
Response represents a decrypted payload from the device.
type ResponseType ¶
type ResponseType int
ResponseType denotes the type of payload.
const ( Unknown ResponseType = iota AuthOK DeviceError Temperature CommandOK RawData RawRFData RawRFData2 )
Enumerations of PayloadType.