goe

package
v0.0.0-...-175a4df Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CloudURI = "https://api.go-e.co"

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	IsV2() bool
	Status() (Response, error)
	Update(payload string) error
}

func NewCloud

func NewCloud(log *util.Logger, token string, cache time.Duration) API

type Card

type Card struct {
	Name   string
	Energy float64
	CardID bool
}

Card is the v2 RFID card

type CloudResponse

type CloudResponse struct {
	Success *bool // only valid for cloud payload commands
	Age     int
	Error   string // only valid for cloud payload commands
	Data    StatusResponse
}

CloudResponse is the cloud API response

type LocalAPI

type LocalAPI struct {
	*request.Helper
	// contains filtered or unexported fields
}

func NewLocal

func NewLocal(log *util.Logger, uri string, cache time.Duration) *LocalAPI

func (*LocalAPI) IsV2

func (c *LocalAPI) IsV2() bool

IsV2 returns v2 api usage

func (*LocalAPI) Status

func (c *LocalAPI) Status() (res Response, err error)

Status reads a v1/v2 api response

func (*LocalAPI) Update

func (c *LocalAPI) Update(payload string) error

Update executes a v1/v2 api update and returns the response

type Response

type Response interface {
	Status() int
	Enabled() bool
	CurrentPower() float64
	ChargedEnergy() float64
	TotalEnergy() float64
	Currents() (float64, float64, float64)
	Voltages() (float64, float64, float64)
	Identify() string
}

Response is the v1 and v2 api response interface

type StatusResponse

type StatusResponse struct {
	Fwv string    `json:"fwv"`        // firmware version
	Car int       `json:"car,string"` // car status
	Alw int       `json:"alw,string"` // allow charging
	Amp int       `json:"amp,string"` // current [A]
	Err int       `json:"err,string"` // error
	Eto int       `json:"eto,string"` // energy total [0.1kWh]
	Stp int       `json:"stp,string"` // stop state
	Tmp int       `json:"tmp,string"` // temperature [°C]
	Dws int       `json:"dws,string"` // energy [Ws]
	Nrg []float64 `json:"nrg"`        // voltage, current, power
	Uby int       `json:"uby,string"` // unlocked_by
	Rna string    `json:"rna"`        // RFID 1
	Rnm string    `json:"rnm"`        // RFID 2
	Rne string    `json:"rne"`        // RFID 3
	Rn4 string    `json:"rn4"`        // RFID 4
	Rn5 string    `json:"rn5"`        // RFID 5
	Rn6 string    `json:"rn6"`        // RFID 6
	Rn7 string    `json:"rn7"`        // RFID 7
	Rn8 string    `json:"rn8"`        // RFID 8
	Rn9 string    `json:"rn9"`        // RFID 9
	Rn1 string    `json:"rn1"`        // RFID 10
}

StatusResponse is the API response if status not OK

func (*StatusResponse) ChargedEnergy

func (g *StatusResponse) ChargedEnergy() float64

func (*StatusResponse) CurrentPower

func (g *StatusResponse) CurrentPower() float64

func (*StatusResponse) Currents

func (g *StatusResponse) Currents() (float64, float64, float64)

func (*StatusResponse) Enabled

func (g *StatusResponse) Enabled() bool

func (*StatusResponse) Identify

func (g *StatusResponse) Identify() string

func (*StatusResponse) Status

func (g *StatusResponse) Status() int

func (*StatusResponse) TotalEnergy

func (g *StatusResponse) TotalEnergy() float64

func (*StatusResponse) Voltages

func (g *StatusResponse) Voltages() (float64, float64, float64)

type StatusResponse2

type StatusResponse2 struct {
	Fwv   string    // firmware version
	Car   int       // car status
	Alw   bool      // allow charging
	Amp   int       // current [A]
	Err   int       // error
	Eto   uint64    // energy total Wh
	Psm   int       // phase switching
	Stp   int       // stop state
	Tmp   int       // temperature [°C]
	Trx   int       // transaction
	Nrg   []float64 // voltage, current, power
	Wh    float64   // energy [Wh]
	Cards []Card    // RFID cards
}

StatusResponse2 is the v2 API response

func (*StatusResponse2) ChargedEnergy

func (g *StatusResponse2) ChargedEnergy() float64

func (*StatusResponse2) CurrentPower

func (g *StatusResponse2) CurrentPower() float64

func (*StatusResponse2) Currents

func (g *StatusResponse2) Currents() (float64, float64, float64)

func (*StatusResponse2) Enabled

func (g *StatusResponse2) Enabled() bool

func (*StatusResponse2) Identify

func (g *StatusResponse2) Identify() string

func (*StatusResponse2) Status

func (g *StatusResponse2) Status() int

func (*StatusResponse2) TotalEnergy

func (g *StatusResponse2) TotalEnergy() float64

func (*StatusResponse2) Voltages

func (g *StatusResponse2) Voltages() (float64, float64, float64)

type UpdateResponse

type UpdateResponse map[string]interface{}

Jump to

Keyboard shortcuts

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