requestPayload.meterStart
)
if (requestPayload.reservationId != null) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const reservation = chargingStation.getReservationBy(
'reservationId',
requestPayload.reservationId
- )!
- if (reservation.idTag !== requestPayload.idTag) {
- logger.warn(
- `${chargingStation.logPrefix()} Reserved transaction ${
- payload.transactionId
- } started with a different idTag ${requestPayload.idTag} than the reservation one ${
- reservation.idTag
- }`
+ )
+ if (reservation != null) {
+ if (reservation.idTag !== requestPayload.idTag) {
+ logger.warn(
+ `${chargingStation.logPrefix()} Reserved transaction ${
+ payload.transactionId
+ } started with a different idTag ${requestPayload.idTag} than the reservation one ${
+ reservation.idTag
+ }`
+ )
+ }
+ if (hasReservationExpired(reservation)) {
+ logger.warn(
+ `${chargingStation.logPrefix()} Reserved transaction ${
+ payload.transactionId
+ } started with expired reservation ${
+ requestPayload.reservationId
+ } (expiry date: ${reservation.expiryDate.toISOString()}))`
+ )
+ }
+ await chargingStation.removeReservation(
+ reservation,
+ ReservationTerminationReason.TRANSACTION_STARTED
)
- }
- if (hasReservationExpired(reservation)) {
+ } else {
logger.warn(
`${chargingStation.logPrefix()} Reserved transaction ${
payload.transactionId
- } started with expired reservation ${
- requestPayload.reservationId
- } (expiry date: ${reservation.expiryDate.toISOString()}))`
+ } started with unknown reservation ${requestPayload.reservationId}`
)
}
- await chargingStation.removeReservation(
- reservation,
- ReservationTerminationReason.TRANSACTION_STARTED
- )
}
chargingStation.stationInfo?.beginEndMeterValues === true &&
(await chargingStation.ocppRequestService.requestHandler<
}
}
if (powerSampledValueTemplate != null) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
checkMeasurandPowerDivider(chargingStation, powerSampledValueTemplate.measurand)
const errMsg = `MeterValues measurand ${
powerSampledValueTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
// Energy.Active.Import.Register measurand (default)
energySampledValueTemplate = getSampledValueTemplate(chargingStation, connectorId)
if (energySampledValueTemplate != null) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
checkMeasurandPowerDivider(chargingStation, energySampledValueTemplate.measurand)
const unitDivider =
energySampledValueTemplate.unit === MeterValueUnit.KILO_WATT_HOUR ? 1000 : 1