From 37f6988a1c25f00ae4bce9a92d7f1a1ef5dd564b Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 3 Mar 2024 14:24:04 +0100 Subject: [PATCH] Planner: don't stop 100% plans (#12392) --- core/loadpoint_plan.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/loadpoint_plan.go b/core/loadpoint_plan.go index f7af10c657..23f81f0edb 100644 --- a/core/loadpoint_plan.go +++ b/core/loadpoint_plan.go @@ -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() @@ -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 }