diff --git a/api/api.go b/api/api.go index 8879c4df6..a6e4ab886 100644 --- a/api/api.go +++ b/api/api.go @@ -37,6 +37,11 @@ type MeterEnergy interface { TotalEnergy() (float64, error) } +// MeterCurrent is able to provide per-line current A +type MeterCurrent interface { + Currents() (float64, float64, float64, error) +} + // Charger is able to provide current charging status and to enable/disabler charging type Charger interface { Status() (ChargeStatus, error) diff --git a/charger/go-e.go b/charger/go-e.go index 6f2c7fe03..c9ee37157 100644 --- a/charger/go-e.go +++ b/charger/go-e.go @@ -139,3 +139,13 @@ func (c *GoE) ChargedEnergy() (float64, error) { energy := float64(status.Dws) / 3.6e6 return energy, err } + +// Currents implements the MeterCurrent interface +func (c *GoE) Currents() (float64, float64, float64, error) { + var status goeStatusResponse + _, err := c.GetJSON(c.apiURL(goeStatus), &status) + if len(status.Nrg) == 16 { + return float64(status.Nrg[4]) / 10, float64(status.Nrg[5]) / 10, float64(status.Nrg[6]) / 10, nil + } + return 0, 0, 0, err +}