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)], ",") } }