isEmptyString,
isNotEmptyArray,
isNotEmptyString,
- isUndefined,
isValidTime,
logger,
secureRandom
const chargingStationInfo = {
chargePointModel: stationTemplate.chargePointModel,
chargePointVendor: stationTemplate.chargePointVendor,
- ...(!isUndefined(stationTemplate.chargeBoxSerialNumberPrefix) && {
+ ...(stationTemplate.chargeBoxSerialNumberPrefix !== undefined && {
chargeBoxSerialNumber: stationTemplate.chargeBoxSerialNumberPrefix
}),
- ...(!isUndefined(stationTemplate.chargePointSerialNumberPrefix) && {
+ ...(stationTemplate.chargePointSerialNumberPrefix !== undefined && {
chargePointSerialNumber: stationTemplate.chargePointSerialNumberPrefix
}),
- ...(!isUndefined(stationTemplate.meterSerialNumberPrefix) && {
+ ...(stationTemplate.meterSerialNumberPrefix !== undefined && {
meterSerialNumber: stationTemplate.meterSerialNumberPrefix
}),
- ...(!isUndefined(stationTemplate.meterType) && {
+ ...(stationTemplate.meterType !== undefined && {
meterType: stationTemplate.meterType
})
}
stationTemplate.Connectors?.[0] != null ? templateMaxConnectors - 1 : templateMaxConnectors
if (
configuredMaxConnectors > templateMaxAvailableConnectors &&
- stationTemplate?.randomConnectors === false
+ stationTemplate?.randomConnectors !== true
) {
logger.warn(
`${logPrefix} Number of connectors exceeds the number of connector configurations in template ${templateFile}, forcing random connector configurations affectation`
if (connectorId === 0) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
connectors.get(connectorId)!.availability = AvailabilityType.Operative
- if (isUndefined(connectors.get(connectorId)?.chargingProfiles)) {
+ if (connectors.get(connectorId)?.chargingProfiles == null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
connectors.get(connectorId)!.chargingProfiles = []
}
return {
chargePointModel: stationInfo.chargePointModel,
chargePointVendor: stationInfo.chargePointVendor,
- ...(!isUndefined(stationInfo.chargeBoxSerialNumber) && {
+ ...(stationInfo.chargeBoxSerialNumber !== undefined && {
chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber
}),
- ...(!isUndefined(stationInfo.chargePointSerialNumber) && {
+ ...(stationInfo.chargePointSerialNumber !== undefined && {
chargePointSerialNumber: stationInfo.chargePointSerialNumber
}),
- ...(!isUndefined(stationInfo.firmwareVersion) && {
+ ...(stationInfo.firmwareVersion !== undefined && {
firmwareVersion: stationInfo.firmwareVersion
}),
- ...(!isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }),
- ...(!isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi }),
- ...(!isUndefined(stationInfo.meterSerialNumber) && {
+ ...(stationInfo.iccid !== undefined && { iccid: stationInfo.iccid }),
+ ...(stationInfo.imsi !== undefined && { imsi: stationInfo.imsi }),
+ ...(stationInfo.meterSerialNumber !== undefined && {
meterSerialNumber: stationInfo.meterSerialNumber
}),
- ...(!isUndefined(stationInfo.meterType) && {
+ ...(stationInfo.meterType !== undefined && {
meterType: stationInfo.meterType
})
} satisfies OCPP16BootNotificationRequest
chargingStation: {
model: stationInfo.chargePointModel,
vendorName: stationInfo.chargePointVendor,
- ...(!isUndefined(stationInfo.firmwareVersion) && {
+ ...(stationInfo.firmwareVersion !== undefined && {
firmwareVersion: stationInfo.firmwareVersion
}),
- ...(!isUndefined(stationInfo.chargeBoxSerialNumber) && {
+ ...(stationInfo.chargeBoxSerialNumber !== undefined && {
serialNumber: stationInfo.chargeBoxSerialNumber
}),
- ...((!isUndefined(stationInfo.iccid) || !isUndefined(stationInfo.imsi)) && {
+ ...((stationInfo.iccid !== undefined || stationInfo.imsi !== undefined) && {
modem: {
- ...(!isUndefined(stationInfo.iccid) && { iccid: stationInfo.iccid }),
- ...(!isUndefined(stationInfo.imsi) && { imsi: stationInfo.imsi })
+ ...(stationInfo.iccid !== undefined && { iccid: stationInfo.iccid }),
+ ...(stationInfo.imsi !== undefined && { imsi: stationInfo.imsi })
}
})
}
templateKey.deprecatedKey,
logPrefix,
templateFile,
- !isUndefined(templateKey.key) ? `Use '${templateKey.key}' instead` : undefined
+ templateKey.key !== undefined ? `Use '${templateKey.key}' instead` : undefined
)
convertDeprecatedTemplateKey(stationTemplate, templateKey.deprecatedKey, templateKey.key)
}
const numberOfConnectors = stationTemplate.numberOfConnectors as number[]
configuredMaxNumberOfConnectors =
numberOfConnectors[Math.floor(secureRandom() * numberOfConnectors.length)]
- } else if (!isUndefined(stationTemplate.numberOfConnectors)) {
+ } else if (stationTemplate.numberOfConnectors != null) {
configuredMaxNumberOfConnectors = stationTemplate.numberOfConnectors as number
} else if (stationTemplate.Connectors != null && stationTemplate.Evses == null) {
configuredMaxNumberOfConnectors =
connectorStatus.transactionStarted = false
connectorStatus.energyActiveImportRegisterValue = 0
connectorStatus.transactionEnergyActiveImportRegisterValue = 0
- if (isUndefined(connectorStatus.chargingProfiles)) {
+ if (connectorStatus.chargingProfiles == null) {
connectorStatus.chargingProfiles = []
}
}
templateFile: string,
logMsgToAppend = ''
): void => {
- if (!isUndefined(template?.[key as keyof ChargingStationTemplate])) {
+ if (template?.[key as keyof ChargingStationTemplate] !== undefined) {
const logMsg = `Deprecated template key '${key}' usage in file '${templateFile}'${
isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : ''
}`
deprecatedKey: string,
key?: string
): void => {
- if (!isUndefined(template?.[deprecatedKey as keyof ChargingStationTemplate])) {
- if (!isUndefined(key)) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- (template as unknown as Record<string, unknown>)[key!] =
+ if (template?.[deprecatedKey as keyof ChargingStationTemplate] !== undefined) {
+ if (key !== undefined) {
+ (template as unknown as Record<string, unknown>)[key] =
template[deprecatedKey as keyof ChargingStationTemplate]
}
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete