#4040: add temporary logging

This commit is contained in:
andig 2022-08-05 19:32:29 +02:00
parent b5c3d949e0
commit 98406ef646
2 changed files with 15 additions and 0 deletions

View file

@ -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 {

View file

@ -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)
}
}