Merge pull request #17679 from evcc-io/fix/repeating_plan_finished
Some checks failed
Some checks failed
Repeating plan: finish behavior
This commit is contained in:
commit
b0dc3b3082
2 changed files with 16 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
// finishPlan deletes the charging plan, either loadpoint or vehicle
|
||||
func (lp *Loadpoint) finishPlan() {
|
||||
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.finishPlan()
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +119,7 @@ func (lp *Loadpoint) plannerActive() (active bool) {
|
|||
return true
|
||||
}
|
||||
|
||||
lp.deletePlan()
|
||||
lp.finishPlan()
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue