tplink

package
v0.0.0-...-6d7b8bb Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection is the TP-Link connection

func NewConnection

func NewConnection(uri string) (*Connection, error)

NewConnection creates TP-Link charger

func (*Connection) CurrentPower

func (d *Connection) CurrentPower() (float64, error)

CurrentPower implements the api.Meter interface

func (*Connection) ExecCmd

func (d *Connection) ExecCmd(cmd string, res interface{}) error

ExecCmd executes an TP-Link Smart Home Protocol command and provides the response

func (*Connection) TotalEnergy

func (d *Connection) TotalEnergy() (float64, error)

TotalEnergy implements the api.MeterEnergy interface

type DayStatResponse

type DayStatResponse struct {
	Emeter struct {
		GetDaystat struct {
			DayList []struct {
				Year  int `json:"year,omitempty"`
				Month int `json:"month,omitempty"`
				Day   int `json:"day,omitempty"`
				// 1st plug generation E-Meter get_daystat Response
				Energy float64 `json:"energy,omitempty"`
				// 2nd plug generation E-Meter get_daystat Response
				EnergyWh float64 `json:"energy_wh,omitempty"`
			} `json:"day_list"`
			// Common E-Meter get_daystat Response
			ErrCode int `json:"err_code,omitempty"`
		} `json:"get_daystat"`
	} `json:"emeter"`
}

DayStatResponse is the TP-Link plug/outlet api emeter get_realtime get_daystat response

type EmeterResponse

type EmeterResponse struct {
	Emeter struct {
		GetRealtime struct {
			// 1st plug generation E-Meter get_realtime Response
			Current float64 `json:"current,omitempty"`
			Voltage float64 `json:"voltage,omitempty"`
			Power   float64 `json:"power,omitempty"`
			Total   float64 `json:"total,omitempty"`
			// 2nd plug generation E-Meter get_realtime Response
			CurrentMa float64 `json:"current_ma,omitempty"`
			VoltageMv float64 `json:"voltage_mv,omitempty"`
			PowerMw   float64 `json:"power_mw,omitempty"`
			TotalWh   float64 `json:"total_wh,omitempty"`
			// Common E-Meter get_realtime Response
			ErrCode int `json:"err_code,omitempty"`
		} `json:"get_realtime"`
	} `json:"emeter"`
}

EmeterResponse is the TP-Link plug/outlet api emeter get_realtime response

type SystemResponse

type SystemResponse struct {
	System struct {
		SetRelayState struct {
			ErrCode int `json:"err_code,omitempty"`
		} `json:"set_relay_state"`
		GetSysinfo struct {
			ErrCode    int    `json:"err_code,omitempty"`
			SwVer      string `json:"sw_ver,omitempty"`
			Model      string `json:"model,omitempty"`
			Alias      string `json:"alias,omitempty"`
			DevName    string `json:"dev_name,omitempty"`
			RelayState int    `json:"relay_state,omitempty"`
			Feature    string `json:"feature,omitempty"`
		} `json:"get_sysinfo"`
	} `json:"system"`
}

SystemResponse is the TP-Link plug/outlet api system response

Jump to

Keyboard shortcuts

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