Go-E: detect phase configuration from voltages (#5764)
This commit is contained in:
parent
e3a449d847
commit
7395777e49
4 changed files with 30 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ type Response interface {
|
|||
ChargedEnergy() float64
|
||||
TotalEnergy() float64
|
||||
Currents() (float64, float64, float64)
|
||||
Voltages() (float64, float64, float64)
|
||||
Identify() string
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue