chore: fix negative remaining plan duration
This commit is contained in:
parent
d5616214a4
commit
47ca5e14de
2 changed files with 4 additions and 1 deletions
|
|
@ -731,7 +731,7 @@ func (lp *Loadpoint) setStatus(status api.ChargeStatus) {
|
|||
|
||||
// remainingChargeEnergy returns missing energy amount in kWh if vehicle has a valid energy target
|
||||
func (lp *Loadpoint) remainingChargeEnergy() (float64, bool) {
|
||||
return float64(lp.targetEnergy) - lp.getChargedEnergy()/1e3,
|
||||
return math.Max(0, lp.targetEnergy-lp.getChargedEnergy()/1e3),
|
||||
(lp.vehicle == nil || lp.vehicleHasFeature(api.Offline)) && lp.targetEnergy > 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ func (lp *Loadpoint) planRequiredDuration(maxPower float64) time.Duration {
|
|||
}
|
||||
|
||||
requiredDuration = lp.socEstimator.RemainingChargeDuration(targetSoc, maxPower)
|
||||
if requiredDuration <= 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// anticipate lower charge rates at end of charging curve
|
||||
var additionalDuration time.Duration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue