p100

package module
v0.0.0-...-c3be863 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 17 Imported by: 1

README

P100-go

Library for communicating with Tapo P100 smart plug.

Example usage:

plug := p100.New("192.168.0.100", "example@gmail.com", "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 * 15

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 P100Cipher

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

func (*P100Cipher) Decrypt

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

func (*P100Cipher) Encrypt

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

type P100Device

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

func New

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

func (*P100Device) CheckErrorCode

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

func (*P100Device) DoRequest

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

func (*P100Device) GetDeviceInfo

func (d *P100Device) GetDeviceInfo() (*P100Status, error)

func (*P100Device) GetURL

func (d *P100Device) GetURL() string

func (*P100Device) Handshake

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

func (*P100Device) Login

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

func (*P100Device) Switch

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

type P100Status

type P100Status 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