tapo

package module
v0.0.0-...-49dce73 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 17 Imported by: 0

README

Tapo Golang

Library for communicating with Tapo devices

Example usage:

plug := tapo.New("192.168.1.11", "user@example.com", "your password")

if err := device.Handshake(); err != nil {
  log.Panic(err)
}

if err := device.Login(); err != nil {
  log.Panic(err)
}

device.Switch(false)

deviceInfo, err := device.GetDeviceInfo()

Documentation

Index

Constants

View Source
const RSABits = 1024
View Source
const Timeout = time.Second * 2

Variables

This section is empty.

Functions

func DumpRSAPEM

func DumpRSAPEM(pubKey *rsa.PublicKey) (pubPEM []byte)

func GenerateRSAKeys

func GenerateRSAKeys() (*rsa.PrivateKey, *rsa.PublicKey)

Types

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(payload []byte) []byte

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(payload []byte) []byte

type Device

type Device struct {
	// contains filtered or unexported fields
}

func New

func New(ip, email, password string) *Device

func (*Device) CheckErrorCode

func (d *Device) CheckErrorCode(errorCode int) error

func (*Device) DoRequest

func (d *Device) DoRequest(payload []byte) ([]byte, error)

func (*Device) GetDeviceInfo

func (d *Device) GetDeviceInfo() (*Status, error)

func (*Device) GetURL

func (d *Device) GetURL() string

func (*Device) Handshake

func (d *Device) Handshake() (err error)

func (*Device) Login

func (d *Device) Login() (err error)

func (*Device) SetDeviceInfo

func (d *Device) SetDeviceInfo(params map[string]interface{}) (err error)

func (*Device) Switch

func (d *Device) Switch(status bool) (err error)

type Status

type Status struct {
	ErrorCode int `json:"error_code"`
	Result    struct {
		DeviceID           string `json:"device_id"`
		FWVersion          string `json:"fw_ver"`
		HWVersion          string `json:"hw_ver"`
		Type               string `json:"type"`
		Model              string `json:"model"`
		MAC                string `json:"mac"`
		HWID               string `json:"hw_id"`
		FWID               string `json:"fw_id"`
		OEMID              string `json:"oem_id"`
		Specs              string `json:"specs"`
		DeviceON           bool   `json:"device_on"`
		OnTime             int    `json:"on_time"`
		OverHeated         bool   `json:"overheated"`
		Nickname           string `json:"nickname"`
		Location           string `json:"location"`
		Avatar             string `json:"avatar"`
		Longitude          int    `json:"longitude"`
		Latitude           int    `json:"latitude"`
		HasSetLocationInfo bool   `json:"has_set_location_info"`
		IP                 string `json:"ip"`
		SSID               string `json:"ssid"`
		SignalLevel        int    `json:"signal_level"`
		RSSI               int    `json:"rssi"`
		Region             string `json:"Europe/Kiev"`
		TimeDiff           int    `json:"time_diff"`
		Lang               string `json:"lang"`
	} `json:"result"`
}

Jump to

Keyboard shortcuts

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