Skip to content

Commit

Permalink
Planner: don't stop 100% plans (#12392)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored and naltatis committed Mar 26, 2024
1 parent 8616134 commit 37f6988
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/loadpoint_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (lp *Loadpoint) GetPlanRequiredDuration(goal, maxPower float64) time.Durati
return time.Duration(energy * 1e3 / maxPower * float64(time.Hour))
}

// GetPlanGoal returns the plan goal and if the goal is soc based
// GetPlanGoal returns the plan goal in %, true or kWh, false
func (lp *Loadpoint) GetPlanGoal() (float64, bool) {
lp.RLock()
defer lp.RUnlock()
Expand Down Expand Up @@ -103,10 +103,15 @@ func (lp *Loadpoint) plannerActive() (active bool) {
return false
}

goal, _ := lp.GetPlanGoal()
goal, isSocBased := lp.GetPlanGoal()
maxPower := lp.EffectiveMaxPower()
requiredDuration := lp.GetPlanRequiredDuration(goal, maxPower)
if requiredDuration <= 0 {
// continue a 100% plan as long as the vehicle is charging
if lp.planActive && isSocBased && goal == 100 && lp.charging() {
return true
}

lp.deletePlan()
return false
}
Expand Down

0 comments on commit 37f6988

Please sign in to comment.