Documentation ¶
Index ¶
- Constants
- func DumpRSAPEM(pubKey *rsa.PublicKey) ([]byte, error)
- func GenerateRSAKeys() (*rsa.PrivateKey, *rsa.PublicKey, error)
- type Connection
- func (d *Connection) ChargedEnergy() (float64, error)
- func (d *Connection) CheckErrorCode(errorCode int) error
- func (d *Connection) CurrentPower() (float64, error)
- func (d *Connection) DoSecureRequest(uri string, taporequest map[string]interface{}) (*DeviceResponse, error)
- func (d *Connection) ExecCmd(method string, enable bool) (*DeviceResponse, error)
- func (d *Connection) ExecMethod(method string, deviceOn bool) (*DeviceResponse, error)
- func (d *Connection) Handshake() error
- func (d *Connection) Login() error
- type ConnectionCipher
- type DeviceResponse
Constants ¶
const Timeout = time.Second * 15
Variables ¶
This section is empty.
Functions ¶
func GenerateRSAKeys ¶
func GenerateRSAKeys() (*rsa.PrivateKey, *rsa.PublicKey, error)
Types ¶
type Connection ¶
type Connection struct { *request.Helper URI string EncodedUser string EncodedPassword string Cipher *ConnectionCipher SessionID string Token string TerminalUUID string // contains filtered or unexported fields }
Connection is the Tapo connection
func NewConnection ¶
func NewConnection(uri, user, password string) (*Connection, error)
NewConnection creates a new Tapo device connection. User is encoded by using MessageDigest of SHA1 which is afterwards B64 encoded. Password is directly B64 encoded.
func (*Connection) ChargedEnergy ¶
func (d *Connection) ChargedEnergy() (float64, error)
ChargedEnergy collects the daily charged energy
func (*Connection) CheckErrorCode ¶
func (d *Connection) CheckErrorCode(errorCode int) error
func (*Connection) CurrentPower ¶
func (d *Connection) CurrentPower() (float64, error)
CurrentPower provides current power consuption
func (*Connection) DoSecureRequest ¶
func (d *Connection) DoSecureRequest(uri string, taporequest map[string]interface{}) (*DeviceResponse, error)
DoSecureRequest executes a Tapo device request by encding the request and decoding its response.
func (*Connection) ExecCmd ¶
func (d *Connection) ExecCmd(method string, enable bool) (*DeviceResponse, error)
ExecCmd executes a Tapo api command and provides the response
func (*Connection) ExecMethod ¶
func (d *Connection) ExecMethod(method string, deviceOn bool) (*DeviceResponse, error)
ExecMethod executes a Tapo device command method and provides the corresponding response.
func (*Connection) Handshake ¶
func (d *Connection) Handshake() error
Handshake provides the Tapo device session cookie and encryption cipher.
func (*Connection) Login ¶
func (d *Connection) Login() error
Login provides the Tapo device session token and MAC address (TerminalUUID).
type ConnectionCipher ¶
Tapo connection cipher
type DeviceResponse ¶
type DeviceResponse struct { 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 int64 `json:"on_time"` OverHeated bool `json:"overheated"` Nickname string `json:"nickname"` Location string `json:"location"` Avatar string `json:"avatar"` Longitude int64 `json:"longitude"` Latitude int64 `json:"latitude"` HasSetLocationInfo bool `json:"has_set_location_info"` IP string `json:"ip"` SSID string `json:"ssid"` SignalLevel int64 `json:"signal_level"` RSSI int64 `json:"rssi"` Region string `json:"Europe/Kiev"` TimeDiff int64 `json:"time_diff"` Lang string `json:"lang"` Key string `json:"key"` Response string `json:"response"` Token string `json:"token"` Current_Power int64 `json:"current_power"` Today_Energy int64 `json:"today_energy"` } `json:"result"` ErrorCode int `json:"error_code"` }
Tapo device response