From 090b0a700e4f5b2142df8774855b47e15a621a83 Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 29 Apr 2024 09:03:55 +0200 Subject: [PATCH] Revert "Loadpoint: add welcomecharge feature (#13534)" This reverts commit 1d4e69591f3f09c7d237fc7685eb6580be370320. --- api/feature.go | 1 - api/feature_enumer.go | 12 ++++-------- core/coordinator/adapter.go | 4 ++-- core/coordinator/api.go | 4 ++-- core/coordinator/coordinator.go | 12 +++--------- core/coordinator/dummy.go | 2 +- core/loadpoint.go | 16 ---------------- core/loadpoint_vehicle.go | 10 +--------- 8 files changed, 13 insertions(+), 48 deletions(-) diff --git a/api/feature.go b/api/feature.go index 44b5240c5..15d7e200f 100644 --- a/api/feature.go +++ b/api/feature.go @@ -10,5 +10,4 @@ const ( IntegratedDevice Heating Retryable - WelcomeCharge ) diff --git a/api/feature_enumer.go b/api/feature_enumer.go index 736284087..858b77ac9 100644 --- a/api/feature_enumer.go +++ b/api/feature_enumer.go @@ -7,11 +7,11 @@ import ( "strings" ) -const _FeatureName = "OfflineCoarseCurrentIntegratedDeviceHeatingRetryableWelcomeCharge" +const _FeatureName = "OfflineCoarseCurrentIntegratedDeviceHeatingRetryable" -var _FeatureIndex = [...]uint8{0, 7, 20, 36, 43, 52, 65} +var _FeatureIndex = [...]uint8{0, 7, 20, 36, 43, 52} -const _FeatureLowerName = "offlinecoarsecurrentintegrateddeviceheatingretryablewelcomecharge" +const _FeatureLowerName = "offlinecoarsecurrentintegrateddeviceheatingretryable" func (i Feature) String() string { i -= 1 @@ -30,10 +30,9 @@ func _FeatureNoOp() { _ = x[IntegratedDevice-(3)] _ = x[Heating-(4)] _ = x[Retryable-(5)] - _ = x[WelcomeCharge-(6)] } -var _FeatureValues = []Feature{Offline, CoarseCurrent, IntegratedDevice, Heating, Retryable, WelcomeCharge} +var _FeatureValues = []Feature{Offline, CoarseCurrent, IntegratedDevice, Heating, Retryable} var _FeatureNameToValueMap = map[string]Feature{ _FeatureName[0:7]: Offline, @@ -46,8 +45,6 @@ var _FeatureNameToValueMap = map[string]Feature{ _FeatureLowerName[36:43]: Heating, _FeatureName[43:52]: Retryable, _FeatureLowerName[43:52]: Retryable, - _FeatureName[52:65]: WelcomeCharge, - _FeatureLowerName[52:65]: WelcomeCharge, } var _FeatureNames = []string{ @@ -56,7 +53,6 @@ var _FeatureNames = []string{ _FeatureName[20:36], _FeatureName[36:43], _FeatureName[43:52], - _FeatureName[52:65], } // FeatureString retrieves an enum value from the enum constants string name. diff --git a/core/coordinator/adapter.go b/core/coordinator/adapter.go index e70082816..1642e750b 100644 --- a/core/coordinator/adapter.go +++ b/core/coordinator/adapter.go @@ -19,8 +19,8 @@ func NewAdapter(lp loadpoint.API, c *Coordinator) API { } } -func (a *adapter) GetVehicles(availableOnly bool) []api.Vehicle { - return a.c.GetVehicles(availableOnly) +func (a *adapter) GetVehicles() []api.Vehicle { + return a.c.GetVehicles() } func (a *adapter) Owner(v api.Vehicle) loadpoint.API { diff --git a/core/coordinator/api.go b/core/coordinator/api.go index 5e2cc9133..6bb196327 100644 --- a/core/coordinator/api.go +++ b/core/coordinator/api.go @@ -7,8 +7,8 @@ import ( // API is the coordinator API type API interface { - // GetVehicles returns the list of all vehicles, filtered by availability - GetVehicles(availableOnly bool) []api.Vehicle + // GetVehicles returns the list of all vehicles + GetVehicles() []api.Vehicle // Owner returns the loadpoint that currently owns the vehicle Owner(api.Vehicle) loadpoint.API diff --git a/core/coordinator/coordinator.go b/core/coordinator/coordinator.go index 01b4e4f3c..3eee8dadb 100644 --- a/core/coordinator/coordinator.go +++ b/core/coordinator/coordinator.go @@ -1,6 +1,7 @@ package coordinator import ( + "slices" "sync" "github.com/evcc-io/evcc/api" @@ -26,18 +27,11 @@ func New(log *util.Logger, vehicles []api.Vehicle) *Coordinator { } // GetVehicles returns the list of all vehicles -func (c *Coordinator) GetVehicles(availableOnly bool) []api.Vehicle { +func (c *Coordinator) GetVehicles() []api.Vehicle { c.mu.RLock() defer c.mu.RUnlock() - res := make([]api.Vehicle, 0, len(c.vehicles)) - for _, v := range c.vehicles { - if _, tracked := c.tracked[v]; !availableOnly || availableOnly && !tracked { - res = append(res, v) - } - } - - return res + return slices.Clone(c.vehicles) } // Owner returns the loadpoint that currently owns the vehicle diff --git a/core/coordinator/dummy.go b/core/coordinator/dummy.go index fddb037ab..07eaee809 100644 --- a/core/coordinator/dummy.go +++ b/core/coordinator/dummy.go @@ -12,7 +12,7 @@ func NewDummy() API { return new(dummy) } -func (a *dummy) GetVehicles(_ bool) []api.Vehicle { +func (a *dummy) GetVehicles() []api.Vehicle { return nil } diff --git a/core/loadpoint.go b/core/loadpoint.go index bdb173fe9..200caf8ac 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -5,7 +5,6 @@ import ( "fmt" "math" "reflect" - "slices" "strings" "sync" "testing" @@ -481,9 +480,6 @@ func (lp *Loadpoint) evVehicleConnectHandler() { lp.socEstimator.Reset() } - // get pv mode before vehicle defaults are applied - pvMode := lp.GetMode() == api.ModePV || lp.GetMode() == api.ModeMinPV - // set default or start detection if !lp.chargerHasFeature(api.IntegratedDevice) { lp.vehicleDefaultOrDetect() @@ -492,18 +488,6 @@ func (lp *Loadpoint) evVehicleConnectHandler() { // immediately allow pv mode activity lp.elapsePVTimer() - // Enable charging on connect if any available vehicle requires it. We're using the PV timer - // to disable after the welcome, hence this must be placed after elapsePVTimer. - // TODO check is this doesn't conflict with vehicle defaults like mode: off - if pvMode { - for _, v := range lp.availableVehicles() { - if slices.Contains(v.Features(), api.WelcomeCharge) { - lp.setLimit(lp.effectiveMinCurrent()) - break - } - } - } - // create charging session lp.createSession() } diff --git a/core/loadpoint_vehicle.go b/core/loadpoint_vehicle.go index c2afa4caf..a8b5b502f 100644 --- a/core/loadpoint_vehicle.go +++ b/core/loadpoint_vehicle.go @@ -20,20 +20,12 @@ const ( vehicleDetectDuration = 10 * time.Minute ) -// availableVehicles is the slice of vehicles from the coordinator that are available -func (lp *Loadpoint) availableVehicles() []api.Vehicle { - if lp.coordinator == nil { - return nil - } - return lp.coordinator.GetVehicles(true) -} - // coordinatedVehicles is the slice of vehicles from the coordinator func (lp *Loadpoint) coordinatedVehicles() []api.Vehicle { if lp.coordinator == nil { return nil } - return lp.coordinator.GetVehicles(false) + return lp.coordinator.GetVehicles() } // setVehicleIdentifier updated the vehicle id as read from the charger