}
})
- this.initialize()
+ this.initialize(options)
this.add()
- if (
- options?.autoStart === true ||
- (options?.autoStart !== false && this.stationInfo?.autoStart === true)
- ) {
+ if (options?.autoStart != null) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.stationInfo!.autoStart = options.autoStart
+ }
+
+ if (this.stationInfo?.autoStart === true) {
this.start()
}
}
}
private getStationInfoFromFile (
- stationInfoPersistentConfiguration = true
+ stationInfoPersistentConfiguration?: boolean
): ChargingStationInfo | undefined {
let stationInfo: ChargingStationInfo | undefined
- if (stationInfoPersistentConfiguration) {
+ if (stationInfoPersistentConfiguration === true) {
stationInfo = this.getConfigurationFromFile()?.stationInfo
if (stationInfo != null) {
delete stationInfo.infoHash
return stationInfo
}
- private getStationInfo (): ChargingStationInfo {
- const defaultStationInfo = Constants.DEFAULT_STATION_INFO
+ private getStationInfo (stationInfoPersistentConfiguration?: boolean): ChargingStationInfo {
const stationInfoFromTemplate = this.getStationInfoFromTemplate()
+ stationInfoPersistentConfiguration != null &&
+ (stationInfoFromTemplate.stationInfoPersistentConfiguration =
+ stationInfoPersistentConfiguration)
const stationInfoFromFile = this.getStationInfoFromFile(
stationInfoFromTemplate.stationInfoPersistentConfiguration
)
stationInfoFromFile != null &&
stationInfoFromFile.templateHash === stationInfoFromTemplate.templateHash
) {
- return { ...defaultStationInfo, ...stationInfoFromFile }
+ return { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromFile }
}
stationInfoFromFile != null &&
propagateSerialNumber(
stationInfoFromFile,
stationInfoFromTemplate
)
- return { ...defaultStationInfo, ...stationInfoFromTemplate }
+ return { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromTemplate }
}
private saveStationInfo (): void {
throw new BaseError(errorMsg)
}
- private initialize (): void {
+ private initialize (options?: ChargingStationOptions): void {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const stationTemplate = this.getTemplateFromFile()!
checkTemplate(stationTemplate, this.logPrefix(), this.templateFile)
} else {
this.initializeConnectorsOrEvsesFromTemplate(stationTemplate)
}
- this.stationInfo = this.getStationInfo()
+ this.stationInfo = this.getStationInfo(options?.persistentConfiguration)
+ if (options?.persistentConfiguration != null) {
+ this.stationInfo.ocppPersistentConfiguration = options.persistentConfiguration
+ }
+ if (options?.persistentConfiguration != null) {
+ this.stationInfo.automaticTransactionGeneratorPersistentConfiguration =
+ options.persistentConfiguration
+ }
+ if (options?.autoRegister != null) {
+ this.stationInfo.autoRegister = options.autoRegister
+ }
if (
this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
isNotEmptyString(this.stationInfo.firmwareVersion) &&
this.bootNotificationRequest = bootNotificationRequest
this.powerDivider = this.getPowerDivider()
// OCPP configuration
- this.ocppConfiguration = this.getOcppConfiguration()
+ this.ocppConfiguration = this.getOcppConfiguration(options?.persistentConfiguration)
this.initializeOcppConfiguration()
this.initializeOcppServices()
if (this.stationInfo.autoRegister === true) {
buildChargingStationAutomaticTransactionGeneratorConfiguration(this)
)
if (
- this.stationInfo?.automaticTransactionGeneratorPersistentConfiguration === false ||
+ this.stationInfo?.automaticTransactionGeneratorPersistentConfiguration !== true ||
this.getAutomaticTransactionGeneratorConfiguration() == null
) {
delete configurationData.automaticTransactionGenerator
return this.getTemplateFromFile()?.Configuration
}
- private getOcppConfigurationFromFile (): ChargingStationOcppConfiguration | undefined {
+ private getOcppConfigurationFromFile (
+ ocppPersistentConfiguration?: boolean
+ ): ChargingStationOcppConfiguration | undefined {
const configurationKey = this.getConfigurationFromFile()?.configurationKey
- if (this.stationInfo?.ocppPersistentConfiguration === true && Array.isArray(configurationKey)) {
+ if (ocppPersistentConfiguration === true && Array.isArray(configurationKey)) {
return { configurationKey }
}
return undefined
}
- private getOcppConfiguration (): ChargingStationOcppConfiguration | undefined {
+ private getOcppConfiguration (
+ ocppPersistentConfiguration: boolean | undefined = this.stationInfo?.ocppPersistentConfiguration
+ ): ChargingStationOcppConfiguration | undefined {
let ocppConfiguration: ChargingStationOcppConfiguration | undefined =
- this.getOcppConfigurationFromFile()
+ this.getOcppConfigurationFromFile(ocppPersistentConfiguration)
if (ocppConfiguration == null) {
ocppConfiguration = this.getOcppConfigurationFromTemplate()
}