Add MeterCurrent interface
This commit is contained in:
parent
4dd1c46497
commit
bbd98d3861
2 changed files with 15 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue