buildUpdatedMessage,
cloneObject,
convertToBoolean,
+ convertToDate,
convertToInt,
exponentialDelay,
formatDurationMilliSeconds,
>(this, RequestCommand.BOOT_NOTIFICATION, this.bootNotificationRequest, {
skipBufferingOnError: true
})
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.bootNotificationResponse.currentTime = convertToDate(
+ this.bootNotificationResponse.currentTime
+ )!
if (!this.isRegistered()) {
this.stationInfo?.registrationMaxRetries !== -1 && ++registrationRetryCount
await sleep(
)
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)
) {
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 {
type OCPP16SupportedFeatureProfiles,
OCPPVersion
} from '../../../types/index.js'
-import { isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
+import { convertToDate, isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
export class OCPP16ServiceUtils extends OCPPServiceUtils {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
}
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ cp.validFrom = convertToDate(cp.validFrom)!
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ cp.validTo = convertToDate(cp.validTo)!
let cpReplaced = false
if (isNotEmptyArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
}
// More efficient time validation function than the one provided by date-fns
-export const isValidTime = (date: unknown): boolean => {
+export const isValidTime = (date: Date | number | undefined): boolean => {
if (typeof date === 'number') {
return !isNaN(date)
} else if (isDate(date)) {