Skip to content

Commit

Permalink
Ocpp: add more phase measurement fallbacks (#16968)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdoda authored Oct 30, 2024
1 parent 0417d78 commit 18ce905
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions charger/ocpp/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 18ce905

Please sign in to comment.