diff --git a/charger/ocpp/connector_core.go b/charger/ocpp/connector_core.go index 63c5c13ae..5890431d7 100644 --- a/charger/ocpp/connector_core.go +++ b/charger/ocpp/connector_core.go @@ -61,12 +61,17 @@ func (conn *Connector) MeterValues(request *core.MeterValuesRequest) (*core.Mete } for _, meterValue := range sortByAge(request.MeterValue) { + if meterValue.Timestamp == nil { + // this should be done before the sorting, but lets assume either all or no sample has a timestamp + meterValue.Timestamp = types.NewDateTime(conn.clock.Now()) + } + // ignore old meter value requests if !meterValue.Timestamp.Time.Before(conn.meterUpdated) { for _, sample := range meterValue.SampledValue { sample.Value = strings.TrimSpace(sample.Value) conn.measurements[getSampleKey(sample)] = sample - conn.meterUpdated = conn.clock.Now() + conn.meterUpdated = meterValue.Timestamp.Time } } }