Ocpp: always use measurement timestamp (#15643)
This commit is contained in:
parent
e622e6706e
commit
26fae8dd60
1 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue