Skip to content

Commit 54ad821

Browse files
Fix nil access
Signed-off-by: Marcel Goerentz <[email protected]>
1 parent c81d61e commit 54ad821

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/loadpoint_effective.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,11 @@ func (lp *Loadpoint) EffectiveMaxPower() float64 {
232232

233233
// effectiveMaxPower returns the effective max power taking vehicle capabilities and phase scaling into account
234234
func (lp *Loadpoint) effectiveMaxPower() float64 {
235-
if maxPower, ok := lp.vehicle.OnIdentified().GetMaxPower(); ok && lp.vehicle != nil {
236-
lp.log.DEBUG.Printf("Max power from vehicle: %.2f kWh", maxPower/1000)
237-
return maxPower
238-
} else {
239-
return Voltage * lp.effectiveMaxCurrent() * float64(lp.maxActivePhases())
235+
if lp.vehicle != nil {
236+
if maxPower, ok := lp.vehicle.OnIdentified().GetMaxPower(); ok {
237+
lp.log.DEBUG.Printf("Max power from vehicle: %.2f kWh", maxPower/1000)
238+
return maxPower
239+
}
240240
}
241+
return Voltage * lp.effectiveMaxCurrent() * float64(lp.maxActivePhases())
241242
}

0 commit comments

Comments
 (0)