-// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
import { createWriteStream, readdirSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
chargingProfile.chargingProfileId
} startSchedule property is not a Date instance. Trying to convert it to a Date instance`
)
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingProfile.chargingSchedule.startSchedule = convertToDate(
chargingProfile.chargingSchedule.startSchedule
- )!
+ )
}
if (chargingProfile.chargingSchedule.duration == null) {
logger.debug(
// OCPP specifies that if duration is not defined, it should be infinite
chargingProfile.chargingSchedule.duration = differenceInSeconds(
maxTime,
- chargingProfile.chargingSchedule.startSchedule
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ chargingProfile.chargingSchedule.startSchedule!
)
}
if (
if (compositeSchedule != null) {
return {
status: GenericStatus.Accepted,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- scheduleStart: compositeSchedule.startSchedule!,
+ scheduleStart: compositeSchedule.startSchedule,
connectorId,
chargingSchedule: compositeSchedule
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const connectorStatus = chargingStation.getConnectorStatus(connectorId!)
if (connectorId != null && isNotEmptyArray(connectorStatus?.chargingProfiles)) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- connectorStatus!.chargingProfiles = []
+ connectorStatus.chargingProfiles = []
logger.debug(
`${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${connectorId}`
)
)
}
const remoteStartTransactionLogMsg = `
- ${chargingStation.logPrefix()} Transaction remotely STARTED on ${chargingStation.stationInfo
- ?.chargingStationId}#${transactionConnectorId} for idTag '${idTag}'`
+ ${chargingStation.logPrefix()} Transaction remotely STARTED on ${
+ chargingStation.stationInfo?.chargingStationId
+ }#${transactionConnectorId} for idTag '${idTag}'`
await OCPP16ServiceUtils.sendAndSetConnectorStatus(
chargingStation,
transactionConnectorId,
)
return OCPP16Constants.OCPP_RESPONSE_EMPTY
}
- let { retrieveDate } = commandPayload
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ commandPayload.retrieveDate = convertToDate(commandPayload.retrieveDate)!
+ const { retrieveDate } = commandPayload
if (chargingStation.stationInfo?.firmwareStatus !== OCPP16FirmwareStatus.Installed) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: firmware update is already in progress`
)
return OCPP16Constants.OCPP_RESPONSE_EMPTY
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- retrieveDate = convertToDate(retrieveDate)!
const now = Date.now()
if (retrieveDate.getTime() <= now) {
this.updateFirmwareSimulation(chargingStation).catch(Constants.EMPTY_FUNCTION)
let ftpClient: Client | undefined
try {
const logFiles = readdirSync(resolve(dirname(fileURLToPath(import.meta.url)), '../'))
- .filter((file) => file.endsWith('.log'))
- .map((file) => join('./', file))
+ .filter(file => file.endsWith('.log'))
+ .map(file => join('./', file))
const diagnosticsArchive = `${chargingStation.stationInfo?.chargingStationId}_logs.tar.gz`
create({ gzip: true }, logFiles).pipe(createWriteStream(diagnosticsArchive))
ftpClient = new Client()
})
let uploadResponse: FTPResponse | undefined
if (accessResponse.code === 220) {
- ftpClient.trackProgress((info) => {
+ ftpClient.trackProgress(info => {
logger.info(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: ${
info.bytes / 1024
>(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
status: OCPP16DiagnosticsStatus.Uploading
})
- .catch((error) => {
+ .catch(error => {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
chargingStation.bootNotificationRequest,
{ skipBufferingOnError: true, triggerMessage: true }
)
- .then((response) => {
+ .then(response => {
chargingStation.bootNotificationResponse = response
})
.catch(Constants.EMPTY_FUNCTION)
) {
return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
}
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ commandPayload.expiryDate = convertToDate(commandPayload.expiryDate)!
const { reservationId, idTag, connectorId } = commandPayload
let response: OCPP16ReserveNowResponse
try {