const transactionId = this.chargingStation.getConnectorStatus(connectorId)?.transactionId;
logger.warn(
`${this.logPrefix(connectorId)} stopping a not started transaction${
- transactionId ? ` ${transactionId.toString()}` : ''
+ !Utils.isNullOrUndefined(transactionId) ? ` ${transactionId?.toString()}` : ''
}`
);
}
? `/${Configuration.getWorker().poolMaxSize?.toString()}`
: ''
} worker(s) concurrently running in '${Configuration.getWorker().processType}' mode${
- this.workerImplementation?.maxElementsPerWorker
+ !Utils.isNullOrUndefined(this.workerImplementation?.maxElementsPerWorker)
? ` (${this.workerImplementation?.maxElementsPerWorker} charging station(s) per worker)`
: ''
}`
return;
} else if (
this.getConnectorStatus(connectorId)?.transactionStarted === true &&
- !this.getConnectorStatus(connectorId)?.transactionId
+ Utils.isNullOrUndefined(this.getConnectorStatus(connectorId)?.transactionId)
) {
logger.error(
`${this.logPrefix()} Trying to start MeterValues on connector Id ${connectorId} with no transaction id`
this.getConnectorStatus(connectorId).idTagAuthorized = false;
this.getConnectorStatus(connectorId).transactionRemoteStarted = false;
this.getConnectorStatus(connectorId).transactionStarted = false;
- delete this.getConnectorStatus(connectorId).localAuthorizeIdTag;
- delete this.getConnectorStatus(connectorId).authorizeIdTag;
- delete this.getConnectorStatus(connectorId).transactionId;
- delete this.getConnectorStatus(connectorId).transactionIdTag;
+ delete this.getConnectorStatus(connectorId)?.localAuthorizeIdTag;
+ delete this.getConnectorStatus(connectorId)?.authorizeIdTag;
+ delete this.getConnectorStatus(connectorId)?.transactionId;
+ delete this.getConnectorStatus(connectorId)?.transactionIdTag;
this.getConnectorStatus(connectorId).transactionEnergyActiveImportRegisterValue = 0;
- delete this.getConnectorStatus(connectorId).transactionBeginMeterValue;
+ delete this.getConnectorStatus(connectorId)?.transactionBeginMeterValue;
this.stopMeterValues(connectorId);
parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(this));
}
stationInfo.firmwareVersionPattern =
stationTemplate?.firmwareVersionPattern ?? Constants.SEMVER_PATTERN;
if (
- stationInfo.firmwareVersion &&
+ !Utils.isEmptyString(stationInfo.firmwareVersion) &&
new RegExp(stationInfo.firmwareVersionPattern).test(stationInfo.firmwareVersion) === false
) {
logger.warn(
},
stationTemplate?.firmwareUpgrade ?? {}
);
- stationInfo.resetTime = stationTemplate?.resetTime
+ stationInfo.resetTime = !Utils.isNullOrUndefined(stationTemplate?.resetTime)
? stationTemplate.resetTime * 1000
: Constants.CHARGING_STATION_DEFAULT_RESET_TIME;
const configuredMaxConnectors =
}
if (
this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
- this.stationInfo.firmwareVersion &&
- this.stationInfo.firmwareVersionPattern
+ !Utils.isEmptyString(this.stationInfo.firmwareVersion) &&
+ !Utils.isEmptyString(this.stationInfo.firmwareVersionPattern)
) {
const versionStep = this.stationInfo.firmwareUpgrade?.versionUpgrade?.step ?? 1;
- const patternGroup: number =
+ const patternGroup: number | undefined =
this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ??
- this.stationInfo.firmwareVersion.split('.').length;
+ this.stationInfo.firmwareVersion?.split('.').length;
const match = this.stationInfo?.firmwareVersion
?.match(new RegExp(this.stationInfo.firmwareVersionPattern))
?.slice(1, patternGroup + 1);
);
}
if (
- this.stationInfo.amperageLimitationOcppKey &&
+ !Utils.isEmptyString(this.stationInfo?.amperageLimitationOcppKey) &&
!ChargingStationConfigurationUtils.getConfigurationKey(
this,
this.stationInfo.amperageLimitationOcppKey
private getAmperageLimitation(): number | undefined {
if (
- this.stationInfo.amperageLimitationOcppKey &&
+ !Utils.isEmptyString(this.stationInfo?.amperageLimitationOcppKey) &&
ChargingStationConfigurationUtils.getConfigurationKey(
this,
this.stationInfo.amperageLimitationOcppKey
})
: '';
stationInfo.chargePointSerialNumber =
- stationTemplate?.chargePointSerialNumberPrefix &&
+ !Utils.isEmptyString(stationTemplate?.chargePointSerialNumberPrefix) &&
`${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`;
stationInfo.chargeBoxSerialNumber =
- stationTemplate?.chargeBoxSerialNumberPrefix &&
+ !Utils.isEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) &&
`${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`;
stationInfo.meterSerialNumber =
- stationTemplate?.meterSerialNumberPrefix &&
+ !Utils.isEmptyString(stationTemplate?.meterSerialNumberPrefix) &&
`${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`;
}
return OCPPConstants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
}
const connectorStatus = chargingStation.getConnectorStatus(commandPayload.connectorId);
- if (commandPayload.connectorId && !Utils.isEmptyArray(connectorStatus?.chargingProfiles)) {
+ if (
+ !Utils.isNullOrUndefined(commandPayload.connectorId) &&
+ !Utils.isEmptyArray(connectorStatus?.chargingProfiles)
+ ) {
connectorStatus.chargingProfiles = [];
logger.debug(
`${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
);
return OCPPConstants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED;
}
- if (!commandPayload.connectorId) {
+ if (Utils.isNullOrUndefined(commandPayload.connectorId)) {
let clearedCP = false;
for (const connectorId of chargingStation.connectors.keys()) {
if (
if (
chargingStation.getLocalAuthListEnabled() === true &&
chargingStation.hasAuthorizedTags() === true &&
- chargingStation.authorizedTagsCache
- .getAuthorizedTags(
- ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
- )
- ?.find((idTag) => idTag === commandPayload.idTag)
+ !Utils.isEmptyString(
+ chargingStation.authorizedTagsCache
+ .getAuthorizedTags(
+ ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
+ )
+ ?.find((idTag) => idTag === commandPayload.idTag)
+ )
) {
connectorStatus.localAuthorizeIdTag = commandPayload.idTag;
connectorStatus.idTagLocalAuthorized = true;
return OCPPConstants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
case OCPP16MessageTrigger.StatusNotification:
setTimeout(() => {
- if (commandPayload?.connectorId) {
+ if (!Utils.isNullOrUndefined(commandPayload?.connectorId)) {
chargingStation.ocppRequestService
.requestHandler<OCPP16StatusNotificationRequest, OCPP16StatusNotificationResponse>(
chargingStation,
} else {
if (authorizeConnectorIdDefined) {
chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = false;
- delete chargingStation.getConnectorStatus(authorizeConnectorId).authorizeIdTag;
+ delete chargingStation.getConnectorStatus(authorizeConnectorId)?.authorizeIdTag;
}
logger.debug(
`${chargingStation.logPrefix()} IdTag '${requestPayload.idTag}' rejected with status '${
const transactionConnectorId = chargingStation.getConnectorIdByTransactionId(
requestPayload.transactionId
);
- if (!transactionConnectorId) {
+ if (Utils.isNullOrUndefined(transactionConnectorId)) {
logger.error(
`${chargingStation.logPrefix()} Trying to stop a non existing transaction ${requestPayload.transactionId.toString()}`
);
chargingStation.resetConnectorStatus(transactionConnectorId);
const logMsg = `${chargingStation.logPrefix()} Transaction ${requestPayload.transactionId.toString()} STOPPED on ${
chargingStation.stationInfo.chargingStationId
- }#${transactionConnectorId.toString()} with status '${
+ }#${transactionConnectorId?.toString()} with status '${
payload.idTagInfo?.status ?? 'undefined'
}'`;
if (
public open(): void {
try {
- if (!this?.fd) {
+ if (this?.fd === undefined && this?.fd === null) {
this.fd = fs.openSync(this.dbName, 'a+');
}
} catch (error) {