From b317bdc46275ba710e7af22479d85e0a3ef0c8a5 Mon Sep 17 00:00:00 2001 From: Florian Egner Date: Fri, 13 Sep 2024 17:25:52 +0200 Subject: [PATCH 1/4] update: add KeyAlfenAuthorizationMethod cost --- charger/ocpp/const.go | 1 + 1 file changed, 1 insertion(+) diff --git a/charger/ocpp/const.go b/charger/ocpp/const.go index be8458eaec..5e6bed0c07 100644 --- a/charger/ocpp/const.go +++ b/charger/ocpp/const.go @@ -20,6 +20,7 @@ const ( KeyMaxChargingProfilesInstalled = "MaxChargingProfilesInstalled" // Vendor specific keys + KeyAlfenAuthorizationMethod = "AuthorizationMethod" KeyAlfenPlugAndChargeIdentifier = "PlugAndChargeIdentifier" KeyEvBoxSupportedMeasurands = "evb_SupportedMeasurands" ) From 2d98b3ef58c87c657ec1144728ffab278cdbc2ce Mon Sep 17 00:00:00 2001 From: Florian Egner Date: Fri, 13 Sep 2024 17:26:38 +0200 Subject: [PATCH 2/4] update: Check if plug and charge is activated --- charger/ocpp/cp_setup.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/charger/ocpp/cp_setup.go b/charger/ocpp/cp_setup.go index 637b8b536f..8b8320bb9b 100644 --- a/charger/ocpp/cp_setup.go +++ b/charger/ocpp/cp_setup.go @@ -80,8 +80,13 @@ func (cp *CP) Setup(meterValues string, meterInterval time.Duration) error { // vendor-specific keys case KeyAlfenPlugAndChargeIdentifier: - cp.IdTag = *opt.Value - cp.log.DEBUG.Printf("overriding default `idTag` with Alfen-specific value: %s", cp.IdTag) + authMethod, exists := getConfigurationValue(resp, KeyAlfenAuthorizationMethod) + + // Override `idTag` with plug-and-charge id if PLUG_AND_CHARGE is configured + if exists && authMethod != "RFID" { + cp.IdTag = *opt.Value + cp.log.DEBUG.Printf("Alfen-specific: overriding `idTag` with PLUG_AND_CHARGE value: %s", cp.IdTag) + } case KeyEvBoxSupportedMeasurands: if meterValues == "" { @@ -146,6 +151,16 @@ func (cp *CP) Setup(meterValues string, meterInterval time.Duration) error { return nil } +// getConfigurationValue returns the value of a configuration key +func getConfigurationValue(resp *core.GetConfigurationConfirmation, key string) (string, bool) { + for _, opt := range resp.ConfigurationKey { + if opt.Key == key && opt.Value != nil { + return *opt.Value, true + } + } + return "", false +} + // GetConfiguration func (cp *CP) GetConfiguration() (*core.GetConfigurationConfirmation, error) { rc := make(chan error, 1) From ab01ecba3c8f4d8fae809f6a96d5c735acd8688d Mon Sep 17 00:00:00 2001 From: Florian Egner Date: Fri, 13 Sep 2024 17:27:09 +0200 Subject: [PATCH 3/4] update: Set idTag for all available connectors during ocpp auth --- charger/ocpp/cp_core.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/charger/ocpp/cp_core.go b/charger/ocpp/cp_core.go index ddb6dcb8a9..cf507d3811 100644 --- a/charger/ocpp/cp_core.go +++ b/charger/ocpp/cp_core.go @@ -21,6 +21,14 @@ func (cp *CP) Authorize(request *core.AuthorizeRequest) (*core.AuthorizeConfirma }, } + // Set idTag for all connectors in available state + for _, conn := range cp.connectors { + if conn.status.Status == core.ChargePointStatusAvailable { + conn.log.INFO.Printf("Set idTag %v from Authorization request", request.IdTag) + conn.idTag = request.IdTag + } + } + return res, nil } From 7055a8218038232311b485ec6fb195c2c77b0f61 Mon Sep 17 00:00:00 2001 From: Florian Egner Date: Sat, 14 Sep 2024 16:39:15 +0200 Subject: [PATCH 4/4] Update charger/ocpp/cp_setup.go Co-authored-by: andig --- charger/ocpp/cp_setup.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charger/ocpp/cp_setup.go b/charger/ocpp/cp_setup.go index 8b8320bb9b..0080dd3527 100644 --- a/charger/ocpp/cp_setup.go +++ b/charger/ocpp/cp_setup.go @@ -80,10 +80,10 @@ func (cp *CP) Setup(meterValues string, meterInterval time.Duration) error { // vendor-specific keys case KeyAlfenPlugAndChargeIdentifier: - authMethod, exists := getConfigurationValue(resp, KeyAlfenAuthorizationMethod) + authMethod, ok := getConfigurationValue(resp, KeyAlfenAuthorizationMethod) // Override `idTag` with plug-and-charge id if PLUG_AND_CHARGE is configured - if exists && authMethod != "RFID" { + if ok && authMethod != "RFID" { cp.IdTag = *opt.Value cp.log.DEBUG.Printf("Alfen-specific: overriding `idTag` with PLUG_AND_CHARGE value: %s", cp.IdTag) }