}
public logPrefix = (): string => {
- if (isNotEmptyString(this.stationInfo?.chargingStationId)) {
- return logPrefix(` ${this.stationInfo?.chargingStationId} |`)
+ if (
+ this instanceof ChargingStation &&
+ this.stationInfo != null &&
+ isNotEmptyString(this.stationInfo.chargingStationId)
+ ) {
+ return logPrefix(` ${this.stationInfo.chargingStationId} |`)
}
let stationTemplate: ChargingStationTemplate | undefined
try {
public getNumberOfPhases (stationInfo?: ChargingStationInfo): number {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const localStationInfo: ChargingStationInfo = stationInfo ?? this.stationInfo!
+ const localStationInfo = stationInfo ?? this.stationInfo!
switch (this.getCurrentOutType(stationInfo)) {
case CurrentType.AC:
return localStationInfo.numberOfPhases ?? 3
public getConnectorMaximumAvailablePower (connectorId: number): number {
let connectorAmperageLimitationPowerLimit: number | undefined
+ const amperageLimitation = this.getAmperageLimitation()
if (
- this.getAmperageLimitation() != null &&
+ amperageLimitation != null &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.getAmperageLimitation()! < this.stationInfo!.maximumAmperage!
+ amperageLimitation < this.stationInfo!.maximumAmperage!
) {
connectorAmperageLimitationPowerLimit =
(this.stationInfo?.currentOutType === CurrentType.AC
this.getNumberOfPhases(),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.stationInfo.voltageOut!,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.getAmperageLimitation()! *
+ amperageLimitation *
(this.hasEvses ? this.getNumberOfEvses() : this.getNumberOfConnectors())
)
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- DCElectricUtils.power(this.stationInfo!.voltageOut!, this.getAmperageLimitation()!)) /
+ DCElectricUtils.power(this.stationInfo!.voltageOut!, amperageLimitation)) /
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.powerDivider!
}
connectorId: number,
reason?: StopTransactionReason
): Promise<StopTransactionResponse> {
- const transactionId = this.getConnectorStatus(connectorId)?.transactionId
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ const transactionId = this.getConnectorStatus(connectorId)!.transactionId!
if (
this.stationInfo?.beginEndMeterValues === true &&
this.stationInfo.ocppStrictCompliance === true &&
const transactionEndMeterValue = buildTransactionEndMeterValue(
this,
connectorId,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.getEnergyActiveImportRegisterByTransactionId(transactionId!)
+ this.getEnergyActiveImportRegisterByTransactionId(transactionId)
)
await this.ocppRequestService.requestHandler<MeterValuesRequest, MeterValuesResponse>(
this,
StopTransactionResponse
>(this, RequestCommand.STOP_TRANSACTION, {
transactionId,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId!, true),
+ meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId, true),
...(reason != null && { reason })
})
}
private getStationInfoFromTemplate (): ChargingStationInfo {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const stationTemplate: ChargingStationTemplate = this.getTemplateFromFile()!
+ const stationTemplate = this.getTemplateFromFile()!
checkTemplate(stationTemplate, this.logPrefix(), this.templateFile)
const warnTemplateKeysDeprecationOnce = once(warnTemplateKeysDeprecation, this)
warnTemplateKeysDeprecationOnce(stationTemplate, this.logPrefix(), this.templateFile)
if (stationTemplate.Connectors != null) {
checkConnectorsConfiguration(stationTemplate, this.logPrefix(), this.templateFile)
}
- const stationInfo: ChargingStationInfo = stationTemplateToStationInfo(stationTemplate)
+ const stationInfo = stationTemplateToStationInfo(stationTemplate)
stationInfo.hashId = getHashId(this.index, stationTemplate)
stationInfo.chargingStationId = getChargingStationId(this.index, stationTemplate)
stationInfo.ocppVersion = stationTemplate.ocppVersion ?? OCPPVersion.VERSION_16
private getStationInfo (): ChargingStationInfo {
const defaultStationInfo = Constants.DEFAULT_STATION_INFO
- const stationInfoFromTemplate: ChargingStationInfo = this.getStationInfoFromTemplate()
- const stationInfoFromFile: ChargingStationInfo | undefined = this.getStationInfoFromFile(
+ const stationInfoFromTemplate = this.getStationInfoFromTemplate()
+ const stationInfoFromFile = this.getStationInfoFromFile(
stationInfoFromTemplate.stationInfoPersistentConfiguration
)
// Priority:
// 1. charging station info from template
// 2. charging station info from configuration file
- if (stationInfoFromFile?.templateHash === stationInfoFromTemplate.templateHash) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- return { ...defaultStationInfo, ...stationInfoFromFile! }
+ if (
+ stationInfoFromFile != null &&
+ stationInfoFromFile.templateHash === stationInfoFromTemplate.templateHash
+ ) {
+ return { ...defaultStationInfo, ...stationInfoFromFile }
}
stationInfoFromFile != null &&
propagateSerialNumber(
isNotEmptyString(this.stationInfo.firmwareVersion) &&
isNotEmptyString(this.stationInfo.firmwareVersionPattern)
) {
- const patternGroup: number | undefined =
+ const patternGroup =
this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ??
this.stationInfo.firmwareVersion?.split('.').length
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (this.stationInfo.enableStatistics === true) {
this.performanceStatistics = PerformanceStatistics.getInstance(
this.stationInfo.hashId,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.stationInfo.chargingStationId!,
+ this.stationInfo.chargingStationId,
this.configuredSupervisionUrl
)
}
- this.bootNotificationRequest = createBootNotificationRequest(this.stationInfo)
+ const bootNotificationRequest = createBootNotificationRequest(this.stationInfo)
+ if (bootNotificationRequest == null) {
+ const errorMsg = 'Error while creating boot notification request'
+ logger.error(`${this.logPrefix()} ${errorMsg}`)
+ throw new BaseError(errorMsg)
+ }
+ this.bootNotificationRequest = bootNotificationRequest
this.powerDivider = this.getPowerDivider()
// OCPP configuration
this.ocppConfiguration = this.getOcppConfiguration()
if (
isNotEmptyString(this.stationInfo?.amperageLimitationOcppKey) &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- getConfigurationKey(this, this.stationInfo!.amperageLimitationOcppKey!) == null
+ getConfigurationKey(this, this.stationInfo.amperageLimitationOcppKey!) == null
) {
addConfigurationKey(
this,
if (!existsSync(dirname(this.configurationFile))) {
mkdirSync(dirname(this.configurationFile), { recursive: true })
}
+ const configurationFromFile = this.getConfigurationFromFile()
let configurationData: ChargingStationConfiguration =
- this.getConfigurationFromFile() != null
- ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- cloneObject<ChargingStationConfiguration>(this.getConfigurationFromFile()!)
+ configurationFromFile != null
+ ? cloneObject<ChargingStationConfiguration>(configurationFromFile)
: {}
if (this.stationInfo?.stationInfoPersistentConfiguration === true) {
configurationData.stationInfo = this.stationInfo
}
private startWebSocketPing (): void {
- const webSocketPingInterval: number =
+ const webSocketPingInterval =
getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval) != null
? convertToInt(
getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval)?.value