`${chargingStation.logPrefix()} Get composite schedule with a specified rate unit is not yet supported, no conversion will be done`
)
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const connectorStatus = chargingStation.getConnectorStatus(connectorId)!
+ const connectorStatus = chargingStation.getConnectorStatus(connectorId)
if (
- isEmptyArray(connectorStatus.chargingProfiles) &&
+ isEmptyArray(connectorStatus?.chargingProfiles) &&
isEmptyArray(chargingStation.getConnectorStatus(0)?.chargingProfiles)
) {
return OCPP16Constants.OCPP_RESPONSE_REJECTED
let previousCompositeSchedule: OCPP16ChargingSchedule | undefined
let compositeSchedule: OCPP16ChargingSchedule | undefined
for (const chargingProfile of chargingProfiles) {
- if (
- chargingProfile.chargingSchedule.startSchedule == null &&
- connectorStatus.transactionStarted === true
- ) {
+ if (chargingProfile.chargingSchedule.startSchedule == null) {
logger.debug(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
chargingProfile.chargingProfileId
} has no startSchedule defined. Trying to set it to the connector current transaction start date`
)
// OCPP specifies that if startSchedule is not defined, it should be relative to start of the connector transaction
- chargingProfile.chargingSchedule.startSchedule = connectorStatus.transactionStart
+ chargingProfile.chargingSchedule.startSchedule = connectorStatus?.transactionStart
}
- if (
- chargingProfile.chargingSchedule.startSchedule != null &&
- !isDate(chargingProfile.chargingSchedule.startSchedule)
- ) {
+ if (!isDate(chargingProfile.chargingSchedule.startSchedule)) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
chargingProfile.chargingProfileId
chargingProfile.chargingSchedule.startSchedule
)!
}
- if (
- chargingProfile.chargingSchedule.startSchedule != null &&
- chargingProfile.chargingSchedule.duration == null
- ) {
+ if (chargingProfile.chargingSchedule.duration == null) {
logger.debug(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
chargingProfile.chargingProfileId
!prepareChargingProfileKind(
connectorStatus,
chargingProfile,
- compositeScheduleInterval.start as Date,
+ compositeScheduleInterval.start,
chargingStation.logPrefix()
)
) {
if (
!canProceedChargingProfile(
chargingProfile,
- compositeScheduleInterval.start as Date,
+ compositeScheduleInterval.start,
chargingStation.logPrefix()
)
) {
? OCPP16ChargePointStatus.Available
: OCPP16ChargePointStatus.Unavailable
if (connectorId === 0) {
- let response: OCPP16ChangeAvailabilityResponse
+ let response: OCPP16ChangeAvailabilityResponse | undefined
if (chargingStation.hasEvses) {
for (const evseStatus of chargingStation.evses.values()) {
response = await OCPP16ServiceUtils.changeAvailability(
)
}
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,
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)
}
)
.catch(Constants.EMPTY_FUNCTION)
- } else {
- if (chargingStation.hasEvses) {
- for (const evseStatus of chargingStation.evses.values()) {
- for (const [id, connectorStatus] of evseStatus.connectors) {
- chargingStation.ocppRequestService
- .requestHandler<
- OCPP16StatusNotificationRequest,
- OCPP16StatusNotificationResponse
- >(
- chargingStation,
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
- connectorId: id,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- status: connectorStatus.status
- },
- {
- triggerMessage: true
- }
- )
- .catch(Constants.EMPTY_FUNCTION)
- }
- }
- } else {
- for (const id of chargingStation.connectors.keys()) {
+ } else if (chargingStation.hasEvses) {
+ for (const evseStatus of chargingStation.evses.values()) {
+ for (const [id, connectorStatus] of evseStatus.connectors) {
chargingStation.ocppRequestService
.requestHandler<
OCPP16StatusNotificationRequest,
{
connectorId: id,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- status: chargingStation.getConnectorStatus(id)?.status
+ status: connectorStatus.status
},
{
triggerMessage: true
.catch(Constants.EMPTY_FUNCTION)
}
}
+ } else {
+ for (const [id, connectorStatus] of chargingStation.connectors) {
+ chargingStation.ocppRequestService
+ .requestHandler<
+ OCPP16StatusNotificationRequest,
+ OCPP16StatusNotificationResponse
+ >(
+ chargingStation,
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ {
+ connectorId: id,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ status: connectorStatus.status
+ },
+ {
+ triggerMessage: true
+ }
+ )
+ .catch(Constants.EMPTY_FUNCTION)
+ }
}
}, OCPP16Constants.OCPP_TRIGGER_MESSAGE_DELAY)
return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
}
await removeExpiredReservations(chargingStation)
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- switch (chargingStation.getConnectorStatus(connectorId)!.status) {
+ switch (chargingStation.getConnectorStatus(connectorId)?.status) {
case OCPP16ChargePointStatus.Faulted:
response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_FAULTED
break