From 65e82e2fef0d335a197d7c2e8ab263554640343f Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 21 Aug 2022 12:49:29 +0200 Subject: [PATCH] Fix vehicle detection starting when no vehicle connected on startup --- core/loadpoint.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index 7e787dae5..93f638b09 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -527,9 +527,8 @@ func (lp *LoadPoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Even lp.publish("minSoC", lp.SoC.Min) lp.Unlock() - // set default or start detection + // reset detection state lp.publish(vehicleDetectionActive, false) - lp.vehicleDefaultOrDetect() // read initial charger state to prevent immediately disabling charger if enabled, err := lp.charger.Enabled(); err == nil { @@ -542,7 +541,7 @@ func (lp *LoadPoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Even lp.log.ERROR.Printf("charger: %v", err) } - // allow charger to access loadpoint + // allow charger to access loadpoint if ctrl, ok := lp.charger.(loadpoint.Controller); ok { ctrl.LoadpointControl(lp) } @@ -891,7 +890,7 @@ func (lp *LoadPoint) vehicleDefaultOrDetect() { // need to do this here since setActiveVehicle would short-circuit lp.addTask(lp.vehicleOdometer) } - } else if len(lp.coordinatedVehicles()) > 0 { + } else if len(lp.coordinatedVehicles()) > 0 && lp.connected() { lp.startVehicleDetection() } }