Planner: always publish current plan (#10667)
This commit is contained in:
parent
613c9c6e76
commit
f90f4ed4c1
3 changed files with 18 additions and 6 deletions
|
|
@ -606,6 +606,13 @@ func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Even
|
|||
lp.publish(chargerIcon, nil)
|
||||
}
|
||||
|
||||
// vehicle
|
||||
lp.publish(vehiclePresent, false)
|
||||
lp.publish(vehicleTitle, "")
|
||||
lp.publish(vehicleIcon, "")
|
||||
lp.publish(vehicleCapacity, 0.0)
|
||||
lp.publish(vehicleOdometer, 0.0)
|
||||
|
||||
// assign and publish default vehicle
|
||||
if lp.defaultVehicle != nil {
|
||||
lp.setActiveVehicle(lp.defaultVehicle)
|
||||
|
|
@ -1561,6 +1568,9 @@ func (lp *Loadpoint) Update(sitePower float64, autoCharge, batteryBuffered, batt
|
|||
mode := lp.GetMode()
|
||||
lp.publish("mode", mode)
|
||||
|
||||
// update and publish plan without being short-circuited by modes etc.
|
||||
plannerActive := lp.plannerActive()
|
||||
|
||||
// execute loading strategy
|
||||
switch {
|
||||
case !lp.connected():
|
||||
|
|
@ -1591,7 +1601,7 @@ func (lp *Loadpoint) Update(sitePower float64, autoCharge, batteryBuffered, batt
|
|||
err = lp.fastCharging()
|
||||
|
||||
// minimum or target charging
|
||||
case lp.minSocNotReached() || lp.plannerActive():
|
||||
case lp.minSocNotReached() || plannerActive:
|
||||
err = lp.fastCharging()
|
||||
lp.resetPhaseTimer()
|
||||
lp.elapsePVTimer() // let PV mode disable immediately afterwards
|
||||
|
|
|
|||
|
|
@ -72,8 +72,12 @@ func (lp *Loadpoint) plannerActive() (active bool) {
|
|||
lp.setPlanActive(active)
|
||||
}()
|
||||
|
||||
maxPower := lp.GetMaxPower()
|
||||
var planStart time.Time
|
||||
defer func() {
|
||||
lp.publish(planProjectedStart, planStart)
|
||||
}()
|
||||
|
||||
maxPower := lp.GetMaxPower()
|
||||
requiredDuration, plan, err := lp.GetPlan(lp.GetTargetTime(), maxPower)
|
||||
if err != nil {
|
||||
lp.log.ERROR.Println("planner:", err)
|
||||
|
|
@ -85,14 +89,12 @@ func (lp *Loadpoint) plannerActive() (active bool) {
|
|||
return false
|
||||
}
|
||||
|
||||
planStart := planner.Start(plan)
|
||||
lp.publish(planProjectedStart, planStart)
|
||||
|
||||
var requiredString string
|
||||
if req := requiredDuration.Round(time.Second); req > planner.Duration(plan).Round(time.Second) {
|
||||
requiredString = fmt.Sprintf(" (required: %v)", req)
|
||||
}
|
||||
|
||||
planStart = planner.Start(plan)
|
||||
lp.log.DEBUG.Printf("plan: charge %v%s starting at %v until %v (power: %.0fW, avg cost: %.3f)",
|
||||
planner.Duration(plan).Round(time.Second), requiredString, planStart.Round(time.Second).Local(), lp.targetTime.Round(time.Second).Local(),
|
||||
maxPower, planner.AverageCost(plan))
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ func (lp *Loadpoint) setActiveVehicle(vehicle api.Vehicle) {
|
|||
lp.publish(vehiclePresent, false)
|
||||
lp.publish(vehicleTitle, "")
|
||||
lp.publish(vehicleIcon, "")
|
||||
lp.publish(vehicleCapacity, int64(0))
|
||||
lp.publish(vehicleCapacity, 0.0)
|
||||
lp.publish(vehicleOdometer, 0.0)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue