Ocpp: add more phase measurement fallbacks (#16968)
Some checks failed
Some checks failed
This commit is contained in:
parent
0417d78117
commit
18ce905742
1 changed files with 12 additions and 15 deletions
|
|
@ -265,10 +265,10 @@ func (conn *Connector) CurrentPower() (float64, error) {
|
|||
}
|
||||
|
||||
// fallback for missing total power
|
||||
|
||||
res, found, err := conn.phaseMeasurements(types.MeasurandPowerActiveImport, "")
|
||||
if found {
|
||||
return res[0] + res[1] + res[2], err
|
||||
for _, suffix := range []types.Measurand{"", "-N"} {
|
||||
if res, found, err := conn.phaseMeasurements(types.MeasurandPowerActiveImport, suffix); found {
|
||||
return res[0] + res[1] + res[2], err
|
||||
}
|
||||
}
|
||||
|
||||
return 0, api.ErrNotAvailable
|
||||
|
|
@ -347,9 +347,10 @@ func (conn *Connector) Currents() (float64, float64, float64, error) {
|
|||
return 0, 0, 0, nil
|
||||
}
|
||||
|
||||
res, found, err := conn.phaseMeasurements(types.MeasurandCurrentImport, "")
|
||||
if found {
|
||||
return res[0], res[1], res[2], err
|
||||
for _, suffix := range []types.Measurand{"", "-N"} {
|
||||
if res, found, err := conn.phaseMeasurements(types.MeasurandCurrentImport, suffix); found {
|
||||
return res[0], res[1], res[2], err
|
||||
}
|
||||
}
|
||||
|
||||
return 0, 0, 0, api.ErrNotAvailable
|
||||
|
|
@ -368,14 +369,10 @@ func (conn *Connector) Voltages() (float64, float64, float64, error) {
|
|||
return 0, 0, 0, api.ErrTimeout
|
||||
}
|
||||
|
||||
res, found, err := conn.phaseMeasurements(types.MeasurandVoltage, "-N")
|
||||
if found {
|
||||
return res[0], res[1], res[2], err
|
||||
}
|
||||
|
||||
res, found, err = conn.phaseMeasurements(types.MeasurandVoltage, "")
|
||||
if found {
|
||||
return res[0], res[1], res[2], err
|
||||
for _, suffix := range []types.Measurand{"-N", ""} {
|
||||
if res, found, err := conn.phaseMeasurements(types.MeasurandVoltage, suffix); found {
|
||||
return res[0], res[1], res[2], err
|
||||
}
|
||||
}
|
||||
|
||||
return 0, 0, 0, api.ErrNotAvailable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue