+ ChargingStationConfigurationUtils.addConfigurationKey(
+ this,
+ StandardParametersKey.ConnectorPhaseRotation,
+ connectorPhaseRotation.toString()
+ );
+ }
+ if (
+ !ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ StandardParametersKey.AuthorizeRemoteTxRequests
+ )
+ ) {
+ ChargingStationConfigurationUtils.addConfigurationKey(
+ this,
+ StandardParametersKey.AuthorizeRemoteTxRequests,
+ 'true'
+ );
+ }
+ if (
+ !ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ StandardParametersKey.LocalAuthListEnabled
+ ) &&
+ ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ StandardParametersKey.SupportedFeatureProfiles
+ )?.value.includes(SupportedFeatureProfiles.LocalAuthListManagement)
+ ) {
+ ChargingStationConfigurationUtils.addConfigurationKey(
+ this,
+ StandardParametersKey.LocalAuthListEnabled,
+ 'false'
+ );
+ }
+ if (
+ !ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ StandardParametersKey.ConnectionTimeOut
+ )
+ ) {
+ ChargingStationConfigurationUtils.addConfigurationKey(
+ this,
+ StandardParametersKey.ConnectionTimeOut,
+ Constants.DEFAULT_CONNECTION_TIMEOUT.toString()
+ );
+ }
+ this.saveOcppConfiguration();
+ }
+
+ private initializeConnectors(
+ stationInfo: ChargingStationInfo,
+ configuredMaxConnectors: number,
+ templateMaxConnectors: number
+ ): void {
+ if (!stationInfo?.Connectors && this.connectors.size === 0) {
+ const logMsg = `No already defined connectors and charging station information from template ${this.templateFile} with no connectors configuration defined`;
+ logger.error(`${this.logPrefix()} ${logMsg}`);
+ throw new BaseError(logMsg);
+ }
+ if (!stationInfo?.Connectors[0]) {
+ logger.warn(
+ `${this.logPrefix()} Charging station information from template ${
+ this.templateFile
+ } with no connector Id 0 configuration`
+ );
+ }
+ if (stationInfo?.Connectors) {
+ const connectorsConfigHash = crypto
+ .createHash(Constants.DEFAULT_HASH_ALGORITHM)
+ .update(JSON.stringify(stationInfo?.Connectors) + configuredMaxConnectors.toString())
+ .digest('hex');
+ const connectorsConfigChanged =
+ this.connectors?.size !== 0 && this.connectorsConfigurationHash !== connectorsConfigHash;
+ if (this.connectors?.size === 0 || connectorsConfigChanged) {
+ connectorsConfigChanged && this.connectors.clear();
+ this.connectorsConfigurationHash = connectorsConfigHash;
+ // Add connector Id 0
+ let lastConnector = '0';
+ for (lastConnector in stationInfo?.Connectors) {
+ const connectorStatus = stationInfo?.Connectors[lastConnector];
+ const lastConnectorId = Utils.convertToInt(lastConnector);
+ if (
+ lastConnectorId === 0 &&
+ this.getUseConnectorId0(stationInfo) === true &&
+ connectorStatus
+ ) {
+ this.checkStationInfoConnectorStatus(lastConnectorId, connectorStatus);
+ this.connectors.set(
+ lastConnectorId,
+ Utils.cloneObject<ConnectorStatus>(connectorStatus)
+ );
+ this.getConnectorStatus(lastConnectorId).availability = AvailabilityType.OPERATIVE;
+ if (Utils.isUndefined(this.getConnectorStatus(lastConnectorId)?.chargingProfiles)) {
+ this.getConnectorStatus(lastConnectorId).chargingProfiles = [];
+ }
+ }
+ }
+ // Generate all connectors
+ if ((stationInfo?.Connectors[0] ? templateMaxConnectors - 1 : templateMaxConnectors) > 0) {
+ for (let index = 1; index <= configuredMaxConnectors; index++) {
+ const randConnectorId = stationInfo?.randomConnectors
+ ? Utils.getRandomInteger(Utils.convertToInt(lastConnector), 1)
+ : index;
+ const connectorStatus = stationInfo?.Connectors[randConnectorId.toString()];
+ this.checkStationInfoConnectorStatus(randConnectorId, connectorStatus);
+ this.connectors.set(index, Utils.cloneObject<ConnectorStatus>(connectorStatus));
+ this.getConnectorStatus(index).availability = AvailabilityType.OPERATIVE;
+ if (Utils.isUndefined(this.getConnectorStatus(index)?.chargingProfiles)) {
+ this.getConnectorStatus(index).chargingProfiles = [];
+ }
+ }
+ }
+ }
+ } else {
+ logger.warn(
+ `${this.logPrefix()} Charging station information from template ${
+ this.templateFile
+ } with no connectors configuration defined, using already defined connectors`