p1XX

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 17 Imported by: 0

README

P100-go

Library for communicating with Tapo P100/P100 smart plugs.

Example usage:

see example.go

Documentation

Index

Constants

View Source
const RSABits = 1024

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, timeout time.Duration) *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) GetEnergyUsage

func (d *P100Device) GetEnergyUsage(status *P100Status) (*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"`
		CurrentPower       int    `json:"current_power"`
		Today_runtime      int    `json:"today_runtime"`
		Month_runtime      int    `json:"month_runtime"`
		Today_energy       int    `json:"today_energy"`
		Month_energy       int    `json:"month_energy"`
		Local_time         string `json:"local_time"`
	} `json:"result"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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