envoy

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 7 Imported by: 0

README

Enphase Envoy Golang Client

This is a golang Enphase Envoy client for communicating with the Envoy communications gateway. It's built and tested against an IQ Envoy. Other models have not been tested. It communicates directly with the unit via the exposed web interface, not the Enphase Enlighten API.

https://enphase.com/en-us/support/what-envoy

Example

import "github.com/gcochard/go-envoy"

client := envoy.NewClient("192.168.0.201")

// Contains data on Production and Consumption, if equipped.
productionData, err := client.Production()

// Contains information on connected devices
inventoryData, err := client.Inventory()

License

This library is provided under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotOK is returned if any of the Envoy APIs does not return a 200
	ErrNotOK = errors.New("server did not return 200")
)

Functions

This section is empty.

Types

type Client

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

Client provides the API for interacting with the Envoy APIs

func NewClient

func NewClient(address string, proto string) *Client

NewClient creates a new Client that will talk to an Envoy unit at *address*, creating its own http.Client underneath.

func NewClientWithHTTP

func NewClientWithHTTP(address string, proto string, client *http.Client) *Client

NewClientWithHTTP creates a new Client that will talk to an Envoy unit at *address* using the provided http.Client.

func (*Client) Inventory

func (c *Client) Inventory() ([]Inventory, error)

Inventory returns the list of parts installed in the system and registered with the Envoy unit

func (*Client) Login added in v1.1.1

func (c *Client) Login() error

func (*Client) Production

func (c *Client) Production() (Production, error)

Production returns the current data for Production and Consumption sensors, if equipped.

func (*Client) SetToken added in v1.1.1

func (c *Client) SetToken(token string)

type DevControl

type DevControl struct {
	Gficlearset bool `json:"gficlearset,omitempty"`
}

DevControl is a list of controls for devices

type Device

type Device struct {
	PartNum        string       `json:"part_num,omitempty"`
	Installed      int          `json:"installed,omitempty"`
	SerialNum      int          `json:"serial_num,omitempty"`
	DeviceStatus   []string     `json:"device_status,omitempty"`
	LastReportDate int          `json:"last_report_date,omitempty"`
	AdminState     int          `json:"admin_state,omitempty"`
	DevType        int          `json:"dev_type,omitempty"`
	CreatedDate    int          `json:"created_date,omitempty"`
	ImgLoadDate    int          `json:"img_load_date,omitempty"`
	ImgPnumRunning string       `json:"img_pnum_running,omitempty"`
	Ptpn           string       `json:"ptpn,omitempty"`
	Chaneid        int          `json:"chaneid,omitempty"`
	DeviceControl  []DevControl `json:"device_control,omitempty"`
	Producing      bool         `json:"producing,omitempty"`
	Communicating  bool         `json:"communicating,omitempty"`
	Provisioned    bool         `json:"provisioned,omitempty"`
	Operating      bool         `json:"operating,omitempty"`
}

Device describes a device attached to the Envoy system

type Inventory

type Inventory struct {
	Type    string   `json:"type,omitempty"`
	Devices []Device `json:"devices,omitempty"`
}

Inventory describes a list of Devices of a certain Type

type Production

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

Production is the collection of all power sensors in the system.

type ProductionData

type ProductionData struct {
	Type             string  `json:"type,omitempty"`
	ActiveCount      int     `json:"activeCount,omitempty"`
	MeasurementType  string  `json:"measurementType,omitempty"`
	ReadingTime      int     `json:"readingTime,omitempty"`
	WNow             float64 `json:"wNow,omitempty"`
	WhLifetime       float64 `json:"whLifetime,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"`
	State            string  `json:"state,omitempty"`
}

ProductionData describes a power reading from a particular sensor. May be a consumption meter.

Jump to

Keyboard shortcuts

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