From dda47c4455b0ac37d489e8d711f38f579eec336d Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Tue, 10 Dec 2024 14:38:02 +0100 Subject: [PATCH 1/3] Repeating plan: fixed finish behaviour --- core/loadpoint.go | 9 +++++++++ core/loadpoint_plan.go | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index 0a2a1e579a..0ce6854283 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -939,6 +939,15 @@ func (lp *Loadpoint) socBasedPlanning() bool { return (v != nil && v.Capacity() > 0) && (lp.vehicleHasSoc() || lp.vehicleSoc > 0) } +// repeatingPlanning returns true if the current plan is a repeating plan +func (lp *Loadpoint) repeatingPlanning() bool { + if !lp.socBasedPlanning() { + return false + } + _, _, id := lp.nextVehiclePlan() + return id > 1 +} + // vehicleHasSoc returns true if active vehicle supports returning soc, i.e. it is not an offline vehicle func (lp *Loadpoint) vehicleHasSoc() bool { return lp.GetVehicle() != nil && !lp.vehicleHasFeature(api.Offline) diff --git a/core/loadpoint_plan.go b/core/loadpoint_plan.go index 90010ac128..2b4ec38130 100644 --- a/core/loadpoint_plan.go +++ b/core/loadpoint_plan.go @@ -28,9 +28,11 @@ func (lp *Loadpoint) setPlanActive(active bool) { } } -// deletePlan deletes the charging plan, either loadpoint or vehicle -func (lp *Loadpoint) deletePlan() { - if !lp.socBasedPlanning() { +// finishedPlan deletes the charging plan, either loadpoint or vehicle +func (lp *Loadpoint) finishedPlan() { + if lp.repeatingPlanning() { + return // noting to do + } else if !lp.socBasedPlanning() { lp.setPlanEnergy(time.Time{}, 0) } else if v := lp.GetVehicle(); v != nil { vehicle.Settings(lp.log, v).SetPlanSoc(time.Time{}, 0) @@ -104,7 +106,7 @@ func (lp *Loadpoint) plannerActive() (active bool) { // keep overrunning plans as long as a vehicle is connected if lp.clock.Until(planTime) < 0 && (!lp.planActive || !lp.connected()) { lp.log.DEBUG.Println("plan: deleting expired plan") - lp.deletePlan() + lp.finishedPlan() return false } @@ -117,7 +119,7 @@ func (lp *Loadpoint) plannerActive() (active bool) { return true } - lp.deletePlan() + lp.finishedPlan() return false } From b0918a52c2f66beedc65009a573c1c877cb25e1b Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Tue, 10 Dec 2024 17:00:21 +0100 Subject: [PATCH 2/3] rename --- core/loadpoint_plan.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/loadpoint_plan.go b/core/loadpoint_plan.go index 2b4ec38130..2fcff9c502 100644 --- a/core/loadpoint_plan.go +++ b/core/loadpoint_plan.go @@ -28,8 +28,8 @@ func (lp *Loadpoint) setPlanActive(active bool) { } } -// finishedPlan deletes the charging plan, either loadpoint or vehicle -func (lp *Loadpoint) finishedPlan() { +// finishePlan deletes the charging plan, either loadpoint or vehicle +func (lp *Loadpoint) finishePlan() { if lp.repeatingPlanning() { return // noting to do } else if !lp.socBasedPlanning() { @@ -106,7 +106,7 @@ func (lp *Loadpoint) plannerActive() (active bool) { // keep overrunning plans as long as a vehicle is connected if lp.clock.Until(planTime) < 0 && (!lp.planActive || !lp.connected()) { lp.log.DEBUG.Println("plan: deleting expired plan") - lp.finishedPlan() + lp.finishePlan() return false } @@ -119,7 +119,7 @@ func (lp *Loadpoint) plannerActive() (active bool) { return true } - lp.finishedPlan() + lp.finishePlan() return false } From fd1270cc1a401f012ef9ca234a2d578125234db4 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Tue, 10 Dec 2024 17:00:54 +0100 Subject: [PATCH 3/3] finish --- core/loadpoint_plan.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/loadpoint_plan.go b/core/loadpoint_plan.go index 2fcff9c502..319fcec288 100644 --- a/core/loadpoint_plan.go +++ b/core/loadpoint_plan.go @@ -28,8 +28,8 @@ func (lp *Loadpoint) setPlanActive(active bool) { } } -// finishePlan deletes the charging plan, either loadpoint or vehicle -func (lp *Loadpoint) finishePlan() { +// finishPlan deletes the charging plan, either loadpoint or vehicle +func (lp *Loadpoint) finishPlan() { if lp.repeatingPlanning() { return // noting to do } else if !lp.socBasedPlanning() { @@ -106,7 +106,7 @@ func (lp *Loadpoint) plannerActive() (active bool) { // keep overrunning plans as long as a vehicle is connected if lp.clock.Until(planTime) < 0 && (!lp.planActive || !lp.connected()) { lp.log.DEBUG.Println("plan: deleting expired plan") - lp.finishePlan() + lp.finishPlan() return false } @@ -119,7 +119,7 @@ func (lp *Loadpoint) plannerActive() (active bool) { return true } - lp.finishePlan() + lp.finishPlan() return false }