connectorId,
)} start transaction with an idTag '${idTag}'`;
if (this.getRequireAuthorize()) {
- this.chargingStation.getConnectorStatus(connectorId)!.authorizeIdTag = idTag;
// Authorize idTag
const authorizeResponse: AuthorizeResponse =
await this.chargingStation.ocppRequestService.requestHandler<
});
++this.connectorsStatus.get(connectorId)!.authorizeRequests!;
if (authorizeResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
+ if (
+ isNullOrUndefined(this.chargingStation.getConnectorStatus(connectorId)!.authorizeIdTag)
+ ) {
+ logger.warn(
+ `${this.chargingStation.logPrefix()} IdTag ${idTag} is not set as authorized remotely, applying deferred initialization`,
+ );
+ this.chargingStation.getConnectorStatus(connectorId)!.authorizeIdTag = idTag;
+ }
++this.connectorsStatus.get(connectorId)!.acceptedAuthorizeRequests!;
logger.info(startTransactionLogMsg);
// Start transaction
type ResetRequest,
type SetChargingProfileRequest,
type SetChargingProfileResponse,
- type StartTransactionRequest,
type UnlockConnectorRequest,
type UnlockConnectorResponse,
} from '../../../types';
commandPayload: RemoteStartTransactionRequest,
): Promise<GenericResponse> {
const { connectorId: transactionConnectorId, idTag, chargingProfile } = commandPayload;
- const reserved =
- chargingStation.getConnectorStatus(transactionConnectorId)!.status ===
- OCPP16ChargePointStatus.Reserved;
- const reservedOnConnectorZero =
- chargingStation.getConnectorStatus(0)!.status === OCPP16ChargePointStatus.Reserved;
if (
- (reserved &&
+ (chargingStation.getConnectorStatus(transactionConnectorId)!.status ===
+ OCPP16ChargePointStatus.Reserved &&
chargingStation.getReservationBy('connectorId', transactionConnectorId)?.idTag !== idTag) ||
- (reservedOnConnectorZero &&
+ (chargingStation.getConnectorStatus(0)!.status === OCPP16ChargePointStatus.Reserved &&
chargingStation.getReservationBy('connectorId', 0)?.idTag !== idTag)
) {
return OCPP16Constants.OCPP_RESPONSE_REJECTED;
OCPP16ChargePointStatus.Preparing,
);
const connectorStatus = chargingStation.getConnectorStatus(transactionConnectorId)!;
- // Check if authorized
if (
chargingStation.getAuthorizeRemoteTxRequests() &&
+ !chargingStation.getLocalAuthListEnabled() &&
+ !chargingStation.getMustAuthorizeAtRemoteStart()
+ ) {
+ logger.warn(
+ `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction
+ but local authorization or must authorize at remote start isn't enabled`,
+ );
+ }
+ // Authorization check required
+ if (
+ chargingStation.getAuthorizeRemoteTxRequests() === true &&
+ chargingStation.getMustAuthorizeAtRemoteStart() === true &&
(await OCPP16ServiceUtils.isIdTagAuthorized(chargingStation, transactionConnectorId, idTag))
) {
// Authorization successful, start transaction
) === true
) {
connectorStatus.transactionRemoteStarted = true;
- const startTransactionPayload: Partial<StartTransactionRequest> = {
- connectorId: transactionConnectorId,
- idTag,
- };
- if (reserved || reservedOnConnectorZero) {
- const reservation = chargingStation.getReservationBy(
- 'connectorId',
- reservedOnConnectorZero ? 0 : transactionConnectorId,
- )!;
- startTransactionPayload.reservationId = reservation.reservationId;
- await chargingStation.removeReservation(
- reservation,
- ReservationTerminationReason.TRANSACTION_STARTED,
- );
- }
if (
(
await chargingStation.ocppRequestService.requestHandler<
OCPP16StartTransactionRequest,
OCPP16StartTransactionResponse
- >(chargingStation, OCPP16RequestCommand.START_TRANSACTION, startTransactionPayload)
+ >(chargingStation, OCPP16RequestCommand.START_TRANSACTION, {
+ connectorId: transactionConnectorId,
+ idTag,
+ })
).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
) {
logger.debug(remoteStartTransactionLogMsg);
const { reservationId, idTag, connectorId } = commandPayload;
let response: OCPP16ReserveNowResponse;
try {
- if (!chargingStation.isConnectorAvailable(connectorId) && connectorId > 0) {
+ if (connectorId > 0 && !chargingStation.isConnectorAvailable(connectorId)) {
return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED;
}
if (connectorId === 0 && !chargingStation.getReserveConnectorZeroSupported()) {
type OCPP16UpdateFirmwareResponse,
OCPPVersion,
RegistrationStatusEnumType,
+ ReservationTerminationReason,
type ResponseHandler,
type SetChargingProfileResponse,
type UnlockConnectorResponse,
}
const authorizeConnectorIdDefined = !isNullOrUndefined(authorizeConnectorId);
if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
- authorizeConnectorIdDefined &&
- (chargingStation.getConnectorStatus(authorizeConnectorId!)!.idTagAuthorized = true);
+ if (authorizeConnectorIdDefined) {
+ chargingStation.getConnectorStatus(authorizeConnectorId!)!.idTagAuthorized = true;
+ chargingStation.getConnectorStatus(authorizeConnectorId!)!.authorizeIdTag =
+ requestPayload.idTag;
+ }
logger.debug(
`${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' accepted${
authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}` : ''
true &&
chargingStation.getAuthorizeRemoteTxRequests() === true &&
chargingStation.getLocalAuthListEnabled() === true &&
- chargingStation.hasIdTags() &&
+ chargingStation.hasIdTags() === true &&
chargingStation.getConnectorStatus(transactionConnectorId)?.idTagLocalAuthorized === false
) {
logger.error(
transactionConnectorId,
requestPayload.meterStart,
);
+ const reservedOnConnectorZero =
+ chargingStation.getConnectorStatus(0)!.status === OCPP16ChargePointStatus.Reserved;
+ if (
+ chargingStation.getConnectorStatus(transactionConnectorId)!.status ===
+ OCPP16ChargePointStatus.Reserved ||
+ reservedOnConnectorZero
+ ) {
+ const reservation = chargingStation.getReservationBy(
+ 'connectorId',
+ reservedOnConnectorZero ? 0 : transactionConnectorId,
+ )!;
+ payload.reservationId = reservation.reservationId;
+ await chargingStation.removeReservation(
+ reservation,
+ ReservationTerminationReason.TRANSACTION_STARTED,
+ );
+ }
chargingStation.getBeginEndMeterValues() &&
(await chargingStation.ocppRequestService.requestHandler<
OCPP16MeterValuesRequest,
connectorStatus.localAuthorizeIdTag = idTag;
connectorStatus.idTagLocalAuthorized = true;
authorized = true;
- } else if (chargingStation.getMustAuthorizeAtRemoteStart() === true) {
- connectorStatus.authorizeIdTag = idTag;
- authorized = await OCPP16ServiceUtils.isIdTagRemoteAuthorized(chargingStation, idTag);
} else {
- logger.warn(
- `${chargingStation.logPrefix()} The charging station configuration expects authorize at
- remote start transaction but local authorization or authorize isn't enabled`,
- );
+ authorized = await OCPP16ServiceUtils.isIdTagRemoteAuthorized(chargingStation, idTag);
+ if (authorized && isNullOrUndefined(connectorStatus.authorizeIdTag)) {
+ logger.warn(
+ `${chargingStation.logPrefix()} IdTag ${idTag} is not set as authorized remotely, applying deferred initialization`,
+ );
+ connectorStatus.authorizeIdTag = idTag;
+ }
}
return authorized;
}
OCPP16AuthorizeRequest,
OCPP16AuthorizeResponse
>(chargingStation, OCPP16RequestCommand.AUTHORIZE, {
- idTag: idTag,
+ idTag,
});
return authorizeResponse?.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED;
}