X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ResponseService.ts;h=3905445e02fde891034802a202403d1b0bfb396b;hb=240fa4da80fd262158004eb576410d02afe0001f;hp=3f311ba56e2687691644f41d04720d170466f412;hpb=68220b423c52da387fdf41967dd8c738da0ff52e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 3f311ba5..3905445e 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -1,6 +1,6 @@ -// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. +// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved. -import type { JSONSchemaType } from 'ajv' +import type { ValidateFunction } from 'ajv' import { secondsToMilliseconds } from 'date-fns' import { OCPP16ServiceUtils } from './OCPP16ServiceUtils.js' @@ -51,19 +51,19 @@ import { type SetChargingProfileResponse, type UnlockConnectorResponse } from '../../../types/index.js' -import { Constants, convertToInt, logger } from '../../../utils/index.js' +import { Constants, convertToInt, isAsyncFunction, logger } from '../../../utils/index.js' import { OCPPResponseService } from '../OCPPResponseService.js' const moduleName = 'OCPP16ResponseService' export class OCPP16ResponseService extends OCPPResponseService { - public jsonIncomingRequestResponseSchemas: Map< + public incomingRequestResponsePayloadValidateFunctions: Map< OCPP16IncomingRequestCommand, - JSONSchemaType + ValidateFunction > + protected payloadValidateFunctions: Map> private readonly responseHandlers: Map - private readonly jsonSchemas: Map> public constructor () { // if (new.target.name === moduleName) { @@ -75,7 +75,7 @@ export class OCPP16ResponseService extends OCPPResponseService { OCPP16RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this) as ResponseHandler ], - [OCPP16RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this) as ResponseHandler], + [OCPP16RequestCommand.HEARTBEAT, this.emptyResponseHandler], [OCPP16RequestCommand.AUTHORIZE, this.handleResponseAuthorize.bind(this) as ResponseHandler], [ OCPP16RequestCommand.START_TRANSACTION, @@ -89,242 +89,346 @@ export class OCPP16ResponseService extends OCPPResponseService { OCPP16RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler.bind(this) as ResponseHandler ], - [OCPP16RequestCommand.METER_VALUES, this.emptyResponseHandler.bind(this) as ResponseHandler], + [OCPP16RequestCommand.METER_VALUES, this.emptyResponseHandler], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, this.emptyResponseHandler.bind(this) as ResponseHandler ], - [OCPP16RequestCommand.DATA_TRANSFER, this.emptyResponseHandler.bind(this) as ResponseHandler], - [ - OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, - this.emptyResponseHandler.bind(this) as ResponseHandler - ] + [OCPP16RequestCommand.DATA_TRANSFER, this.emptyResponseHandler], + [OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, this.emptyResponseHandler] ]) - this.jsonSchemas = new Map>([ + this.payloadValidateFunctions = new Map>([ [ OCPP16RequestCommand.BOOT_NOTIFICATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.HEARTBEAT, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.AUTHORIZE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.START_TRANSACTION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.STOP_TRANSACTION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.METER_VALUES, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.DATA_TRANSFER, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', - moduleName, - 'constructor' - ) + this.ajv + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ] ]) - this.jsonIncomingRequestResponseSchemas = new Map([ + this.incomingRequestResponsePayloadValidateFunctions = new Map< + OCPP16IncomingRequestCommand, + ValidateFunction + >([ [ OCPP16IncomingRequestCommand.RESET, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ResetResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ResetResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.RESERVE_NOW, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ], [ OCPP16IncomingRequestCommand.CANCEL_RESERVATION, - OCPP16ServiceUtils.parseJsonSchemaFile( - 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', - moduleName, - 'constructor' - ) + this.ajvIncomingRequest + .compile( + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', + moduleName, + 'constructor' + ) + ) + .bind(this) ] ]) - this.validatePayload = this.validatePayload.bind(this) as ( - chargingStation: ChargingStation, - commandName: OCPP16RequestCommand, - payload: JsonType - ) => boolean + this.validatePayload = this.validatePayload.bind(this) } public async responseHandler( @@ -341,7 +445,18 @@ export class OCPP16ResponseService extends OCPPResponseService { try { this.validatePayload(chargingStation, commandName, payload) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await this.responseHandlers.get(commandName)!(chargingStation, payload, requestPayload) + const responseHandler = this.responseHandlers.get(commandName)! + if (isAsyncFunction(responseHandler)) { + await responseHandler(chargingStation, payload, requestPayload) + } else { + ( + responseHandler as ( + chargingStation: ChargingStation, + payload: JsonType, + requestPayload?: JsonType + ) => void + )(chargingStation, payload, requestPayload) + } } catch (error) { logger.error( `${chargingStation.logPrefix()} ${moduleName}.responseHandler: Handle response error:`, @@ -353,7 +468,7 @@ export class OCPP16ResponseService extends OCPPResponseService { // Throw exception throw new OCPPError( ErrorType.NOT_IMPLEMENTED, - `${commandName} is not implemented to handle response PDU ${JSON.stringify( + `'${commandName}' is not implemented to handle response PDU ${JSON.stringify( payload, undefined, 2 @@ -369,7 +484,7 @@ export class OCPP16ResponseService extends OCPPResponseService { payload, undefined, 2 - )} while the charging station is not registered on the central server.`, + )} while the charging station is not registered on the central server`, commandName, payload ) @@ -381,17 +496,11 @@ export class OCPP16ResponseService extends OCPPResponseService { commandName: OCPP16RequestCommand, payload: JsonType ): boolean { - if (this.jsonSchemas.has(commandName)) { - return this.validateResponsePayload( - chargingStation, - commandName, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.jsonSchemas.get(commandName)!, - payload - ) + if (this.payloadValidateFunctions.has(commandName)) { + return this.validateResponsePayload(chargingStation, commandName, payload) } logger.warn( - `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation` + `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema validation function found for command '${commandName}' PDU validation` ) return false } @@ -460,29 +569,30 @@ export class OCPP16ResponseService extends OCPPResponseService { } } } - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const authorizeConnectorStatus = chargingStation.getConnectorStatus(authorizeConnectorId!) - const authorizeConnectorIdDefined = authorizeConnectorId != null - if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) { - if (authorizeConnectorIdDefined) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - authorizeConnectorStatus!.idTagAuthorized = true + if (authorizeConnectorId != null) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const authorizeConnectorStatus = chargingStation.getConnectorStatus(authorizeConnectorId)! + if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) { + authorizeConnectorStatus.idTagAuthorized = true + logger.debug( + `${chargingStation.logPrefix()} idTag '${ + requestPayload.idTag + }' accepted on connector id ${authorizeConnectorId}` + ) + } else { + authorizeConnectorStatus.idTagAuthorized = false + delete authorizeConnectorStatus.authorizeIdTag + logger.debug( + `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' rejected with status '${ + payload.idTagInfo.status + }'` + ) } - logger.debug( - `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' accepted${ - authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}` : '' - }` - ) } else { - if (authorizeConnectorIdDefined) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - authorizeConnectorStatus!.idTagAuthorized = false - delete authorizeConnectorStatus?.authorizeIdTag - } - logger.debug( - `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' rejected with status '${ - payload.idTagInfo.status - }'${authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}` : ''}` + logger.error( + `${chargingStation.logPrefix()} idTag '${ + requestPayload.idTag + }' has no authorize request pending` ) } } @@ -614,33 +724,40 @@ export class OCPP16ResponseService extends OCPPResponseService { 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< @@ -681,8 +798,9 @@ export class OCPP16ResponseService extends OCPPResponseService { logger.warn( `${chargingStation.logPrefix()} Starting transaction with id ${ payload.transactionId - } REJECTED on ${chargingStation.stationInfo - ?.chargingStationId}#${connectorId} with status '${payload.idTagInfo.status}', idTag '${ + } REJECTED on ${ + chargingStation.stationInfo?.chargingStationId + }#${connectorId} with status '${payload.idTagInfo.status}', idTag '${ requestPayload.idTag }'${ OCPP16ServiceUtils.hasReservation(chargingStation, connectorId, requestPayload.idTag) @@ -699,8 +817,7 @@ export class OCPP16ResponseService extends OCPPResponseService { connectorId: number ): Promise { const connectorStatus = chargingStation.getConnectorStatus(connectorId) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - resetConnectorStatus(connectorStatus!) + resetConnectorStatus(connectorStatus) chargingStation.stopMeterValues(connectorId) if (connectorStatus?.status !== OCPP16ChargePointStatus.Available) { await OCPP16ServiceUtils.sendAndSetConnectorStatus( @@ -764,13 +881,13 @@ export class OCPP16ResponseService extends OCPPResponseService { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion chargingStation.powerDivider!-- } - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId)!) + resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId)) chargingStation.stopMeterValues(transactionConnectorId) const logMsg = `${chargingStation.logPrefix()} Transaction with id ${ requestPayload.transactionId - } STOPPED on ${chargingStation.stationInfo - ?.chargingStationId}#${transactionConnectorId} with status '${payload.idTagInfo?.status}'` + } STOPPED on ${ + chargingStation.stationInfo?.chargingStationId + }#${transactionConnectorId} with status '${payload.idTagInfo?.status}'` if ( payload.idTagInfo == null || payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED