diff --git a/core/loadpoint.go b/core/loadpoint.go index 9e9f1844d..c7079a7cd 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -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 diff --git a/core/loadpoint_plan.go b/core/loadpoint_plan.go index 94002aa04..914f23081 100644 --- a/core/loadpoint_plan.go +++ b/core/loadpoint_plan.go @@ -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)) diff --git a/core/loadpoint_vehicle.go b/core/loadpoint_vehicle.go index e3a696d0d..2ec6539ab 100644 --- a/core/loadpoint_vehicle.go +++ b/core/loadpoint_vehicle.go @@ -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) }