Planner: adjust session energy by initial value plan (#25149)

This commit is contained in:
Christian Güdel 2025-11-09 13:29:04 +01:00 • committed by GitHub
parent 2291b371e3
commit da22c62073
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View file

@ -148,6 +148,7 @@ type Loadpoint struct {
planTime time.Time // time goal
planPrecondition time.Duration // precondition duration
planEnergy float64 // Plan charge energy in kWh (dumb vehicles)
planEnergyOffset float64 // already charged energy in kWh when plan was set
planSlotEnd time.Time // current plan slot end time
planActive bool // charge plan exists and has a currently active slot
@ -514,6 +515,9 @@ func (lp *Loadpoint) evVehicleConnectHandler() {
// create charging session
lp.createSession()
// reset energy-based charging plan offset
lp.planEnergyOffset = 0
}
// evVehicleDisconnectHandler sends external start event

View file

@ -368,6 +368,7 @@ func (lp *Loadpoint) setPlanEnergy(finishAt time.Time, precondition time.Duratio
lp.planTime = finishAt
lp.planPrecondition = precondition
lp.planEnergyOffset = lp.getChargedEnergy() / 1e3
lp.publish(keys.PlanTime, finishAt)
lp.publish(keys.PlanPrecondition, precondition)
lp.settings.SetTime(keys.PlanTime, finishAt)

View file

@ -37,7 +37,7 @@ func (lp *Loadpoint) finishPlan() {
// remainingPlanEnergy returns missing energy amount in kWh
func (lp *Loadpoint) remainingPlanEnergy(planEnergy float64) float64 {
return max(0, planEnergy-lp.getChargedEnergy()/1e3)
return max(0, planEnergy-(lp.getChargedEnergy()/1e3-lp.planEnergyOffset))
}
// GetPlanRequiredDuration is the estimated total charging duration