Ocpp: use phase powers as fallback (#15602)
This commit is contained in:
parent
b28889bd65
commit
4a3200b8e5
1 changed files with 17 additions and 1 deletions
|
|
@ -236,7 +236,23 @@ func (conn *Connector) CurrentPower() (float64, error) {
|
|||
return scale(f, m.Unit), err
|
||||
}
|
||||
|
||||
return 0, api.ErrNotAvailable
|
||||
// fallback for missing total power
|
||||
var res float64
|
||||
for phase := 1; phase <= 3; phase++ {
|
||||
m, ok := conn.measurements[getPhaseKey(types.MeasurandPowerActiveImport, phase)]
|
||||
if !ok {
|
||||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
||||
f, err := strconv.ParseFloat(m.Value, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid power for phase %d: %w", phase, err)
|
||||
}
|
||||
|
||||
res += scale(f, m.Unit)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (conn *Connector) TotalEnergy() (float64, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue