Go-E: detect phase configuration from voltages (#5764)

This commit is contained in:
andig 2023-01-12 16:12:46 +01:00 • committed by GitHub
parent e3a449d847
commit 7395777e49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 0 deletions

View file

@ -176,6 +176,20 @@ func (c *GoE) Currents() (float64, float64, float64, error) {
return i1, i2, i3, err
}
var _ api.PhaseVoltages = (*GoE)(nil)
// Voltages implements the api.PhaseVoltages interface
func (c *GoE) Voltages() (float64, float64, float64, error) {
resp, err := c.api.Status()
if err != nil {
return 0, 0, 0, err
}
u1, u2, u3 := resp.Voltages()
return u1, u2, u3, err
}
var _ api.Identifier = (*GoE)(nil)
// Identify implements the api.Identifier interface

View file

@ -20,6 +20,7 @@ type Response interface {
ChargedEnergy() float64
TotalEnergy() float64
Currents() (float64, float64, float64)
Voltages() (float64, float64, float64)
Identify() string
}

View file

@ -63,6 +63,13 @@ func (g *StatusResponse) Currents() (float64, float64, float64) {
return 0, 0, 0
}
func (g *StatusResponse) Voltages() (float64, float64, float64) {
if len(g.Nrg) == 16 {
return g.Nrg[0], g.Nrg[1], g.Nrg[2]
}
return 0, 0, 0
}
func (g *StatusResponse) Identify() string {
switch g.Uby {
case 1:

View file

@ -56,6 +56,14 @@ func (g *StatusResponse2) Currents() (float64, float64, float64) {
return 0, 0, 0
}
func (g *StatusResponse2) Voltages() (float64, float64, float64) {
if len(g.Nrg) == 16 {
return g.Nrg[0], g.Nrg[1], g.Nrg[2]
}
return 0, 0, 0
}
func (g *StatusResponse2) Identify() string {
if g.Trx > 0 {
return g.Cards[g.Trx-1].Name