From 98406ef6469686e72cb4950037b29eadbb3f2450 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 5 Aug 2022 19:32:29 +0200 Subject: [PATCH] #4040: add temporary logging --- core/coordinator.go | 5 +++++ core/loadpoint.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/core/coordinator.go b/core/coordinator.go index 8b753c08e..27c57e747 100644 --- a/core/coordinator.go +++ b/core/coordinator.go @@ -4,6 +4,7 @@ import ( "github.com/evcc-io/evcc/api" "github.com/evcc-io/evcc/core/loadpoint" "github.com/evcc-io/evcc/util" + "github.com/samber/lo" ) type vehicleCoordinator struct { @@ -49,6 +50,10 @@ func (lp *vehicleCoordinator) availableDetectibleVehicles(owner loadpoint.API, v func (lp *vehicleCoordinator) identifyVehicleByStatus(log *util.Logger, owner loadpoint.API, vehicles []api.Vehicle) api.Vehicle { available := lp.availableDetectibleVehicles(owner, vehicles) + log.DEBUG.Printf("#4040 coordinator.identifyVehicleByStatus - available %v", lo.Map(available, func(v api.Vehicle, _ int) string { + return v.Title() + })) // TODO remove + var res api.Vehicle for _, vehicle := range available { if vs, ok := vehicle.(api.ChargeState); ok { diff --git a/core/loadpoint.go b/core/loadpoint.go index d12c65977..a562baaeb 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -491,6 +491,8 @@ func (lp *LoadPoint) evChargeCurrentWrappedMeterHandler(current float64) { // applyAction executes the action func (lp *LoadPoint) applyAction(actionCfg api.ActionConfig) { + lp.log.DEBUG.Printf("#4040 applyAction: %+v", actionCfg) // TODO remove + if actionCfg.Mode != nil { lp.SetMode(*actionCfg.Mode) } @@ -732,6 +734,7 @@ func (lp *LoadPoint) remoteControlled(demand loadpoint.RemoteDemand) bool { // setVehicleIdentifier updated the vehicle id as read from the charger func (lp *LoadPoint) setVehicleIdentifier(id string) { if lp.vehicleIdentifier != id { + lp.log.DEBUG.Printf("#4040 setVehicleIdentifier: %s", id) // TODO remove lp.vehicleIdentifier = id lp.publish("vehicleIdentity", id) } @@ -768,9 +771,12 @@ func (lp *LoadPoint) identifyVehicle() { // selectVehicleByID selects the vehicle with the given ID func (lp *LoadPoint) selectVehicleByID(id string) api.Vehicle { + lp.log.DEBUG.Printf("#4040 selectVehicleByID: %s", id) // TODO remove + // find exact match for _, vehicle := range lp.vehicles { if slices.Contains(vehicle.Identifiers(), id) { + lp.log.DEBUG.Printf("#4040 selectVehicleByID found: %s", vehicle.Title()) // TODO remove return vehicle } } @@ -803,6 +809,8 @@ func (lp *LoadPoint) setActiveVehicle(vehicle api.Vehicle) { return } + lp.log.DEBUG.Printf("#4040 setActiveVehicle: %s", vehicle.Title()) // TODO remove + from := "unknown" if lp.vehicle != nil { coordinator.release(lp.vehicle) @@ -927,12 +935,14 @@ func (lp *LoadPoint) identifyVehicleByStatus() { } if vehicle := coordinator.identifyVehicleByStatus(lp.log, lp, lp.vehicles); vehicle != nil { + lp.log.DEBUG.Printf("#4040 identifyVehicleByStatus - activate %s", vehicle.Title()) // TODO remove lp.setActiveVehicle(vehicle) return } // remove previous vehicle if status was not confirmed if _, ok := lp.vehicle.(api.ChargeState); ok { + lp.log.DEBUG.Printf("#4040 identifyVehicleByStatus - remove previous") // TODO remove lp.setActiveVehicle(nil) } }