Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- type Device
- type DeviceInfo
- type DeviceUsage
- type DiscoverResponse
- type DiscoverV1Request
- type EnergyUsage
- type GetDeviceInfoRequest
- type GetDeviceInfoResponse
- type GetDeviceUsageRequest
- type GetDeviceUsageResponse
- type GetEnergyUsageRequest
- type GetEnergyUsageResponse
- type GetInfo
- type GetSysinfo
- type HandshakeRequest
- type HandshakeResponse
- type KlapSession
- type LoginDeviceRequest
- type LoginDeviceResponse
- type PassthroughSession
- type Plug
- func (p *Plug) GetDeviceInfo() (*DeviceInfo, error)
- func (p *Plug) GetDeviceUsage() (*DeviceUsage, error)
- func (p *Plug) GetEnergyUsage() (*EnergyUsage, error)
- func (p *Plug) Handshake(username, password string) error
- func (p *Plug) IsOn() (bool, error)
- func (p *Plug) Off() error
- func (p *Plug) On() error
- func (p *Plug) SetDeviceInfo(deviceOn bool) error
- type SecurePassthroughRequest
- type SecurePassthroughResponse
- type Session
- type SetDeviceInfoRequest
- type SetDeviceInfoResponse
- type TapoError
Constants ¶
View Source
const DiscoverV1InitializationVector = 0xab
Variables ¶
View Source
var ErrForbidden = errors.New("Forbidden")
This is returned when a Tapo device returns an HTTP 403.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a tp-link cloud client for cloud-based operations.
func (*Client) CloudLogin ¶
func (*Client) Discover ¶
func (c *Client) Discover() (map[string]DiscoverResponse, []DiscoverResponse, error)
type Device ¶
type Device struct { DeviceType string `json:"deviceType"` Role int `json:"role"` FwVer string `json:"fwVer"` AppServerURL string `json:"appServerUrl"` DeviceRegion string `json:"deviceRegion"` DeviceID string `json:"deviceId"` DeviceName string `json:"deviceName"` DeviceHwVer string `json:"deviceHwVer"` Alias string `json:"alias"` DeviceMAC tapoMAC `json:"deviceMac"` OemID string `json:"oemId"` DeviceModel string `json:"deviceModel"` HwID string `json:"hwId"` FwID string `json:"fwId"` IsSameRegion bool `json:"isSameRegion"` Status int `json:"status"` // Computed values DecodedAlias string }
type DeviceInfo ¶
type DeviceInfo 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"` IP string `json:"ip"` TimeDiff int `json:"time_diff"` SSID string `json:"ssid"` RSSI int `json:"rssi"` SignalLevel int `json:"signal_level"` Latitude int `json:"latitude"` Longitude int `json:"longitude"` Lang string `json:"lang"` Avatar string `json:"avatar"` Region string `json:"region"` Specs string `json:"specs"` Nickname string `json:"nickname"` HasSetLocationInfo bool `json:"has_set_location_info"` DeviceON bool `json:"device_on"` OnTime int `json:"on_time"` DefaultStates struct { Type string `json:"type"` // TODO add the structure for State State *json.RawMessage `json:"state"` } `json:"default_states"` OverHeated bool `json:"overheated"` PowerProtectionStatus string `json:"power_protection_status,omitempty"` Location string `json:"location,omitempty"` // Computed values below. // DecodedSSID is the decoded version of the base64-encoded SSID field. DecodedSSID string // DecodedNickname is the decoded version of the base64-encoded Nickname field. DecodedNickname string }
TODO differentiate fields between P100 and P110
type DeviceUsage ¶
type DeviceUsage struct { TimeUsage struct { Today int `json:"today"` Past7 int `json:"past7"` Past30 int `json:"past30"` } `json:"time_usage"` PowerUsage struct { Today int `json:"today"` Past7 int `json:"past7"` Past30 int `json:"past30"` } `json:"power_usage"` SavedPower struct { Today int `json:"today"` Past7 int `json:"past7"` Past30 int `json:"past30"` } `json:"saved_power"` }
type DiscoverResponse ¶
type DiscoverResponse struct { Result struct { DeviceID string `json:"device_id"` Owner string `json:"owner"` DeviceType string `json:"device_type"` DeviceModel string `json:"device_model"` IP xjson.IP `json:"ip"` MAC xjson.HardwareAddr `json:"mac"` IsSupportIOTCloud bool `json:"is_support_iot_clout"` ObdSrc string `json:"obd_src"` FactoryDefault bool `json:"factory_default"` MgtEncryptSchm struct { IsSupportHTTPS bool `json:"is_support_https"` EncryptType string `json:"encrypt_type"` HTTPPort int `json:"http_port"` Lv int `json:"lv"` } `json:"mgt_encrypt_schm"` ErrorCode int `json:"error_code"` } `json:"result"` }
type DiscoverV1Request ¶
type DiscoverV1Request struct { System GetSysinfo `json:"system"` CnCloud GetInfo `json:"cnCloud"` IOTCommonCloud GetInfo `json:"smartlife.iot.common.cloud"` CamIpcameraCloud GetInfo `json:"smartlife.cam.ipcamera.cloud"` }
func NewDiscoverV1Request ¶
func NewDiscoverV1Request() *DiscoverV1Request
type EnergyUsage ¶
type EnergyUsage struct { TodayRuntime int `json:"today_runtime"` MonthRuntime int `json:"month_runtime"` TodayEnergy int `json:"today_energy"` MonthEnergy int `json:"month_energy"` LocalTime string `json:"local_time"` ElectricityCharge [3]int `json:"electricity_charge"` CurrentPower int `json:"current_power"` }
type GetDeviceInfoRequest ¶
type GetDeviceInfoRequest struct { Method string `json:"method"` RequestTimeMils int `json:"requestTimeMils"` }
func NewGetDeviceInfoRequest ¶
func NewGetDeviceInfoRequest() *GetDeviceInfoRequest
type GetDeviceInfoResponse ¶
type GetDeviceInfoResponse struct { ErrorCode TapoError `json:"error_code"` Result DeviceInfo `json:"result"` }
type GetDeviceUsageRequest ¶
type GetDeviceUsageRequest struct { Method string `json:"method"` RequestTimeMils int `json:"requestTimeMils"` }
func NewGetDeviceUsageRequest ¶
func NewGetDeviceUsageRequest() *GetDeviceUsageRequest
type GetDeviceUsageResponse ¶
type GetDeviceUsageResponse struct { ErrorCode TapoError `json:"error_code"` Result DeviceUsage `json:"result"` }
type GetEnergyUsageRequest ¶
type GetEnergyUsageRequest struct { Method string `json:"method"` RequestTimeMils int `json:"requestTimeMils"` }
func NewGetEnergyUsageRequest ¶
func NewGetEnergyUsageRequest() *GetEnergyUsageRequest
type GetEnergyUsageResponse ¶
type GetEnergyUsageResponse struct { ErrorCode TapoError `json:"error_code"` Result EnergyUsage `json:"result"` }
type GetSysinfo ¶
type HandshakeRequest ¶
type HandshakeRequest struct { Method string `json:"method"` RequestTimeMils int `json:"requestTimeMils"` Params struct { Key string `json:"key"` } `json:"params"` }
func NewHandshakeRequest ¶
func NewHandshakeRequest(key string) *HandshakeRequest
type HandshakeResponse ¶
type KlapSession ¶
type KlapSession struct { SessionID string Expiry time.Time LocalSeed []byte RemoteSeed []byte UserHash []byte // contains filtered or unexported fields }
func NewKlapSession ¶
func NewKlapSession(l *log.Logger) *KlapSession
func (*KlapSession) Addr ¶
func (s *KlapSession) Addr() netip.Addr
type LoginDeviceRequest ¶
type LoginDeviceRequest struct { Method string `json:"method"` RequestTimeMils int `json:"requestTimeMils"` Params struct { Username string `json:"username"` Password string `json:"password"` } `json:"params"` }
func NewLoginDeviceRequest ¶
func NewLoginDeviceRequest(username, password string) *LoginDeviceRequest
type LoginDeviceResponse ¶
type PassthroughSession ¶
type PassthroughSession struct { Key []byte IV []byte ID string // contains filtered or unexported fields }
func NewPassthroughSession ¶
func NewPassthroughSession(l *log.Logger) *PassthroughSession
func (*PassthroughSession) Addr ¶
func (p *PassthroughSession) Addr() netip.Addr
type Plug ¶
func (*Plug) GetDeviceInfo ¶
func (p *Plug) GetDeviceInfo() (*DeviceInfo, error)
func (*Plug) GetDeviceUsage ¶
func (p *Plug) GetDeviceUsage() (*DeviceUsage, error)
func (*Plug) GetEnergyUsage ¶
func (p *Plug) GetEnergyUsage() (*EnergyUsage, error)
func (*Plug) SetDeviceInfo ¶
type SecurePassthroughRequest ¶
type SecurePassthroughRequest struct { Method string `json:"method"` Params struct { Request string `json:"request"` } `json:"params"` }
func NewSecurePassthroughRequest ¶
func NewSecurePassthroughRequest(innerRequest string) *SecurePassthroughRequest
type SetDeviceInfoRequest ¶
type SetDeviceInfoRequest struct { Method string `json:"method"` Params struct { DeviceOn bool `json:"device_on"` } `json:"params"` }
func NewSetDeviceInfoRequest ¶
func NewSetDeviceInfoRequest(deviceOn bool) *SetDeviceInfoRequest
type SetDeviceInfoResponse ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.