envoy

package module
v0.0.0-...-53a2f2d Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: BSD-2-Clause Imports: 13 Imported by: 2

README

LICENSE GoReportCard GoDoc Go

go-envoy

Pull data from an Enphase IQ Envoy or IQ Combiner

This uses the local API, not the Cloud API, so you can poll as frequently as you like

Only basic features will be supported

  • reading inventory
  • reading current consumption/production/storage data

Usage

First argument is the command you want to run, second argument is the IP address or hostname of your IQ. If no IP/hostname is passed in the application will attempt to find the IQ on your network.

% envoy <command> <envoy IP/hostname>

Examples

  • see current production / max, consumption, net statistics
  • max is calculated based on the sum of the highest production each panel has produced since last IQ reboot
% envoy now
Production: 6698.88W / 8808W	Consumption: 722.03W	Net: -5976.85W

Or pass in the IP of your IQ

% envoy now 192.168.0.123
Production: 6698.88W / 8808W    Consumption: 722.03W    Net: -5976.85W
  • see today's totals
% envoy today
Production: 13.55kWh	Consumption: 8.58kWh	Net: 0.00kWh
  • see envoy info
% envoy info
Serial Number:  xxx
Part Number:  800-00555-r03
Software Version:  R4.10.35

Building

  • Requires go1.15 or newer.
% go build -o envoy cmd/envoy/main.go

TO DO

This does what I need, if there are features you'd like, please let me know

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Discover

func Discover(ctx context.Context) (string, error)

func GetToken

func GetToken(ctx context.Context, username, password, serialNumber string) (string, error)

Types

type Entry

type Entry struct {
	Type             string  `json:"type"`
	MeasurementType  string  `json:"measurementType"`
	State            string  `json:"state,omitempty"`
	Lines            []Line  `json:"lines,omitempty"`
	ActiveCount      int     `json:"activeCount"`
	ReadingTime      int     `json:"readingTime"`
	WNow             float64 `json:"wNow,omitempty"`
	WhLifetime       float64 `json:"whLifetime,omitempty"`
	WhNow            float64 `json:"whNow,omitempty"`
	VarhLeadLifetime float64 `json:"varhLeadLifetime,omitempty"`
	VarhLagLifetime  float64 `json:"varhLagLifetime,omitempty"`
	VahLifetime      float64 `json:"vahLifetime,omitempty"`
	RmsCurrent       float64 `json:"rmsCurrent,omitempty"`
	RmsVoltage       float64 `json:"rmsVoltage,omitempty"`
	ReactPwr         float64 `json:"reactPwr,omitempty"`
	ApprntPwr        float64 `json:"apprntPwr,omitempty"`
	PwrFactor        float64 `json:"pwrFactor,omitempty"`
	WhToday          float64 `json:"whToday,omitempty"`
	WhLastSevenDays  float64 `json:"whLastSevenDays,omitempty"`
	VahToday         float64 `json:"vahToday,omitempty"`
	VarhLeadToday    float64 `json:"varhLeadToday,omitempty"`
	VarhLagToday     float64 `json:"varhLagToday,omitempty"`
}

type Envoy

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

func New

func New(host, token string) *Envoy

func (*Envoy) Home

func (e *Envoy) Home(ctx context.Context) (*home, error)

func (*Envoy) Info

func (e *Envoy) Info(ctx context.Context) (*EnvoyInfo, error)

func (*Envoy) Inventory

func (e *Envoy) Inventory(ctx context.Context) (*[]Inventory, error)

func (*Envoy) Inverters

func (e *Envoy) Inverters(ctx context.Context) (*[]Inverter, error)

func (*Envoy) Now

func (e *Envoy) Now(ctx context.Context) (tp, tc, net float64, err error)

func (*Envoy) Production

func (e *Envoy) Production(ctx context.Context) (*Production, error)

type EnvoyInfo

type EnvoyInfo struct {
	Device struct {
		Text     string `xml:",chardata"`
		Sn       string `xml:"sn"`
		Pn       string `xml:"pn"`
		Software string `xml:"software"`
		Euaid    string `xml:"euaid"`
		Seqnum   string `xml:"seqnum"`
		Apiver   string `xml:"apiver"`
		Imeter   string `xml:"imeter"`
	} `xml:"device"`
	BuildInfo struct {
		Text         string `xml:",chardata"`
		BuildTimeGmt string `xml:"build_time_gmt"`
		BuildID      string `xml:"build_id"`
	} `xml:"build_info"`
	XMLName xml.Name `xml:"envoy_info"`
	Text    string   `xml:",chardata"`
	Time    string   `xml:"time"`
	Package []struct {
		Text    string `xml:",chardata"`
		Name    string `xml:"name,attr"`
		Pn      string `xml:"pn"`
		Version string `xml:"version"`
		Build   string `xml:"build"`
	} `xml:"package"`
}

type Inventory

type Inventory struct {
	Type    string `json:"type"`
	Devices []struct {
		PartNum        string   `json:"part_num"`
		Installed      string   `json:"installed"`
		SerialNum      string   `json:"serial_num"`
		LastRptDate    string   `json:"last_rpt_date"`
		CreatedDate    string   `json:"created_date"`
		ImgLoadDate    string   `json:"img_load_date"`
		ImgPnumRunning string   `json:"img_pnum_running"`
		Ptpn           string   `json:"ptpn"`
		DeviceStatus   []string `json:"device_status"`
		DeviceControl  []struct {
			Gficlearset bool `json:"gficlearset"`
		} `json:"device_control"`
		AdminState    int  `json:"admin_state"`
		DevType       int  `json:"dev_type"`
		Chaneid       int  `json:"chaneid"`
		Producing     bool `json:"producing"`
		Communicating bool `json:"communicating"`
		Provisioned   bool `json:"provisioned"`
		Operating     bool `json:"operating"`
	} `json:"devices"`
}

Inventory

type Inverter

type Inverter struct {
	SerialNumber    string `json:"serialNumber"`
	LastReportDate  uint64 `json:"lastReportDate"`
	DevType         uint8  `json:"devType"`
	LastReportWatts int16  `json:"lastReportWatts"`
	MaxReportWatts  uint16 `json:"maxReportWatts"`
}

requires authentication http://envoy.local/api/v1/production/inverters uint8 for Watts might be good enough, but mine are hitting 246...

type Line

type Line struct {
	WNow             float64 `json:"wNow"`
	WhLifetime       float64 `json:"whLifetime"`
	VarhLeadLifetime float64 `json:"varhLeadLifetime"`
	VarhLagLifetime  float64 `json:"varhLagLifetime"`
	VahLifetime      float64 `json:"vahLifetime"`
	RmsCurrent       float64 `json:"rmsCurrent"`
	RmsVoltage       float64 `json:"rmsVoltage"`
	ReactPwr         float64 `json:"reactPwr"`
	ApprntPwr        float64 `json:"apprntPwr"`
	PwrFactor        float64 `json:"pwrFactor"`
	WhToday          float64 `json:"whToday"`
	WhLastSevenDays  float64 `json:"whLastSevenDays"`
	VahToday         float64 `json:"vahToday"`
	VarhLeadToday    float64 `json:"varhLeadToday"`
	VarhLagToday     float64 `json:"varhLagToday"`
}

type Production

type Production struct {
	Production  []Entry `json:"production"`
	Consumption []Entry `json:"consumption"`
	Storage     []Entry `json:"storage"`
}

from the production endpoint

type Stream

type Stream struct {
	Production       streamSet `json:"production"`
	NetConsumption   streamSet `json:"net-consumption"`
	TotalConsumption streamSet `json:"total-consumption"`
}

Stream is the type for the webstream

Directories

Path Synopsis
cmd
envoy command
logger command

Jump to

Keyboard shortcuts

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