ediplug

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteCommand

func ExecuteCommand(c Command, ip string, password string) error

ExecuteCommand sends a command to a plug and parses the answer. The response can be found in the command object

Types

type Command

type Command interface {
	GetXML() ([]byte, error)
	Parse(in io.Reader) error
}

Command is an interface wich includes a XML generator and a XML parser

type GetEnergyCommand

type GetEnergyCommand struct {
	LastToggleTime time.Time
	NowCurrent     float64 // Measured in Ampere
	NowPower       float64 // Measured in Watts
	DailyEnergy    float64 // Measured in kWh
	WeeklyEnergy   float64 // Measured in kWh
	MonthlyEnergy  float64 // Measured in kWh
	// contains filtered or unexported fields
}

GetEnergyCommand retrieves the energy stats from the plug

func (*GetEnergyCommand) GetXML

func (g *GetEnergyCommand) GetXML() ([]byte, error)

GetXML assembles the request XML

func (*GetEnergyCommand) Parse

func (g *GetEnergyCommand) Parse(in io.Reader) error

Parse parses data from the response XML

type GetStateCommand

type GetStateCommand struct {
	CurrentState string
	// contains filtered or unexported fields
}

GetStateCommand retrieves the current state from the plug (CurrentState will be "ON" or "OFF")

func (*GetStateCommand) GetXML

func (g *GetStateCommand) GetXML() ([]byte, error)

GetXML assembles the request XML

func (*GetStateCommand) Parse

func (g *GetStateCommand) Parse(in io.Reader) error

Parse parses data from the response XML

type GetSystemInfoCommand

type GetSystemInfoCommand struct {
	Model           string
	FirmwareVersion string
	MacAddress      string
	SystemName      string
	DeviceTime      time.Time
	// contains filtered or unexported fields
}

GetSystemInfoCommand retrieves general information about the plug

func (*GetSystemInfoCommand) GetXML

func (g *GetSystemInfoCommand) GetXML() ([]byte, error)

GetXML assembles the request XML

func (*GetSystemInfoCommand) Parse

func (g *GetSystemInfoCommand) Parse(in io.Reader) error

Parse parses data from the response XML

type SetStateCommand

type SetStateCommand struct {
	DesiredState string
	Success      bool
}

SetStateCommand switches a plug on or off. DesiredState needs to be set to "ON" or "OFF" (in caps)

func (*SetStateCommand) GetXML

func (s *SetStateCommand) GetXML() ([]byte, error)

GetXML assembles the request XML

func (*SetStateCommand) Parse

func (s *SetStateCommand) Parse(in io.Reader) error

Parse parses data from the response XML

Jump to

Keyboard shortcuts

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