From 167203214322c73dea38aa4bd2b030186f875d2a Mon Sep 17 00:00:00 2001 From: andig Date: Tue, 6 Aug 2024 12:53:09 +0200 Subject: [PATCH] Ocpp: fix setting measurands --- charger/ocpp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charger/ocpp.go b/charger/ocpp.go index 083120970..7d7c20aaa 100644 --- a/charger/ocpp.go +++ b/charger/ocpp.go @@ -271,8 +271,8 @@ func NewOCPP(id string, connector int, idtag string, // autodetect measurands if meterValues == "" && meterValuesSampledDataMaxLength > 0 { sampledMeasurands := c.tryMeasurands(desiredMeasurands, ocpp.KeyMeterValuesSampledData) - if len(sampledMeasurands) > meterValuesSampledDataMaxLength { - meterValues = strings.Join(sampledMeasurands[:meterValuesSampledDataMaxLength], ",") + if l := len(sampledMeasurands); l > 0 { + meterValues = strings.Join(sampledMeasurands[:min(l, meterValuesSampledDataMaxLength)], ",") } }