From 8605c6726375a82020267f2a455cee1aa4af00e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 21 Oct 2025 18:26:03 +0200 Subject: [PATCH] refactor: cleanup OCPP2 commands implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 2 +- .../ocpp/2.0/OCPP20Constants.ts | 7 -- .../ocpp/2.0/OCPP20IncomingRequestService.ts | 101 +++++++++--------- .../ocpp/2.0/OCPP20RequestService.ts | 1 - src/types/ConnectorStatus.ts | 2 + src/types/index.ts | 6 +- src/types/ocpp/2.0/Common.ts | 39 +++++-- src/types/ocpp/2.0/Requests.ts | 48 +++------ src/types/ocpp/2.0/Responses.ts | 4 +- src/types/ocpp/2.0/Variables.ts | 71 +++++++----- src/types/ocpp/ConnectorEnumType.ts | 7 ++ 11 files changed, 152 insertions(+), 136 deletions(-) create mode 100644 src/types/ocpp/ConnectorEnumType.ts diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 9ebf8aa0..8b530e2a 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -146,7 +146,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, - this.handleRequestClearCache.bind(this) as IncomingRequestHandler, + super.handleRequestClearCache.bind(this) as IncomingRequestHandler, ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, diff --git a/src/charging-station/ocpp/2.0/OCPP20Constants.ts b/src/charging-station/ocpp/2.0/OCPP20Constants.ts index 93c37f40..c94fbe9f 100644 --- a/src/charging-station/ocpp/2.0/OCPP20Constants.ts +++ b/src/charging-station/ocpp/2.0/OCPP20Constants.ts @@ -5,13 +5,6 @@ import { import { OCPPConstants } from '../OCPPConstants.js' export class OCPP20Constants extends OCPPConstants { - static readonly ComponentName = { - CHARGING_STATION: 'ChargingStation', - CONNECTOR: 'Connector', - EVSE: 'EVSE', - OCPP_COMM_CTRLR: 'OCPPCommCtrlr', - } as const - static readonly ChargingStationStatusTransitions: readonly ConnectorStatusTransition[] = Object.freeze([ { to: OCPP20ConnectorStatusEnumType.Available }, diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 05ce66aa..1fb65e8c 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -6,13 +6,13 @@ import type { ChargingStation } from '../../../charging-station/index.js' import { OCPPError } from '../../../exception/index.js' import { - type ComponentType, + ConnectorEnumType, ErrorType, - type EVSEType, GenericDeviceModelStatusEnumType, type IncomingRequestHandler, type JsonType, type OCPP20ClearCacheRequest, + OCPP20ComponentName, type OCPP20GetBaseReportRequest, type OCPP20GetBaseReportResponse, OCPP20IncomingRequestCommand, @@ -22,13 +22,9 @@ import { OCPPVersion, ReportBaseEnumType, type ReportDataType, - type VariableAttributeType, - type VariableCharacteristicsType, - type VariableType, } from '../../../types/index.js' import { isAsyncFunction, logger } from '../../../utils/index.js' import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js' -import { OCPP20Constants } from './OCPP20Constants.js' import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js' const moduleName = 'OCPP20IncomingRequestService' @@ -47,7 +43,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { // } super(OCPPVersion.VERSION_201) this.incomingRequestHandlers = new Map([ - [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)], + [OCPP20IncomingRequestCommand.CLEAR_CACHE, super.handleRequestClearCache.bind(this)], [OCPP20IncomingRequestCommand.GET_BASE_REPORT, this.handleRequestGetBaseReport.bind(this)], ]) this.payloadValidateFunctions = new Map< @@ -84,13 +80,14 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { response: OCPP20GetBaseReportResponse ) => { if (response.status === GenericDeviceModelStatusEnumType.Accepted) { - const { requestId, reportBase } = request + const { reportBase, requestId } = request const reportData = this.buildReportData(chargingStation, reportBase) chargingStation.ocppRequestService .requestHandler( chargingStation, OCPP20RequestCommand.NOTIFY_REPORT, { + generatedAt: new Date(), reportData, requestId, seqNo: 0, @@ -98,9 +95,11 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { } ) .then(() => { - logger.info( + logger.debug( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `${chargingStation.logPrefix()} ${moduleName}.constructor: NotifyReport sent for requestId ${requestId} with ${reportData.length} report items` ) + return undefined }) .catch((error: unknown) => { logger.error( @@ -203,34 +202,12 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { this.emit(commandName, chargingStation, commandPayload, response) } - private handleRequestGetBaseReport ( - chargingStation: ChargingStation, - commandPayload: OCPP20GetBaseReportRequest - ): OCPP20GetBaseReportResponse { - logger.info( - `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: GetBaseReport request received with requestId ${commandPayload.requestId} and reportBase ${commandPayload.reportBase}` - ) - // Build report data to check if any data is available - const reportData = this.buildReportData(chargingStation, commandPayload.reportBase) - if (reportData.length === 0) { - logger.info( - `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: No data available for reportBase ${commandPayload.reportBase}` - ) - return { - status: GenericDeviceModelStatusEnumType.EmptyResultSet, - } - } - return { - status: GenericDeviceModelStatusEnumType.Accepted, - } - } - private buildReportData ( chargingStation: ChargingStation, - reportBase: string + reportBase: ReportBaseEnumType ): ReportDataType[] { // Validate reportBase parameter - if (!Object.values(ReportBaseEnumType).includes(reportBase as ReportBaseEnumType)) { + if (!Object.values(ReportBaseEnumType).includes(reportBase)) { logger.warn( `${chargingStation.logPrefix()} ${moduleName}.buildReportData: Invalid reportBase '${reportBase}'` ) @@ -246,7 +223,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { for (const configKey of chargingStation.ocppConfiguration.configurationKey) { reportData.push({ component: { - name: OCPP20Constants.ComponentName.OCPP_COMM_CTRLR, + name: OCPP20ComponentName.OCPPCommCtrlr, }, variable: { name: configKey.key, @@ -273,7 +250,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { const stationInfo = chargingStation.stationInfo if (stationInfo.chargePointModel) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: OCPP20ComponentName.DeviceDataCtrlr }, variable: { name: 'Model' }, variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointModel }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -281,7 +258,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { } if (stationInfo.chargePointVendor) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: OCPP20ComponentName.DeviceDataCtrlr }, variable: { name: 'VendorName' }, variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointVendor }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -289,7 +266,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { } if (stationInfo.chargePointSerialNumber) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: OCPP20ComponentName.DeviceDataCtrlr }, variable: { name: 'SerialNumber' }, variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointSerialNumber }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -297,7 +274,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { } if (stationInfo.firmwareVersion) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: OCPP20ComponentName.DeviceDataCtrlr }, variable: { name: 'FirmwareVersion' }, variableAttribute: [{ type: 'Actual', value: stationInfo.firmwareVersion }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -309,7 +286,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { if (chargingStation.ocppConfiguration?.configurationKey) { for (const configKey of chargingStation.ocppConfiguration.configurationKey) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.OCPP_COMM_CTRLR }, + component: { name: OCPP20ComponentName.OCPPCommCtrlr }, variable: { name: configKey.key }, variableAttribute: [{ type: 'Actual', value: configKey.value }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -323,22 +300,22 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { reportData.push({ component: { evse: { id: evseId }, - name: 'EVSE', + name: OCPP20ComponentName.DeviceDataCtrlr, }, variable: { name: 'AvailabilityState' }, variableAttribute: [{ type: 'Actual', value: evse.availability }], variableCharacteristics: { dataType: 'string', supportsMonitoring: true }, }) - if (evse.connectors) { + if (evse.connectors.size > 0) { for (const [connectorId, connector] of evse.connectors) { reportData.push({ component: { - evse: { connectorId, id: evseId }, - name: 'Connector', + evse: { connectorId: connectorId.toString(), id: evseId }, + name: OCPP20ComponentName.DeviceDataCtrlr, }, variable: { name: 'ConnectorType' }, variableAttribute: [ - { type: 'Actual', value: String(connector.connectorType) }, + { type: 'Actual', value: connector.type ?? ConnectorEnumType.Unknown }, ], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, }) @@ -351,11 +328,13 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { if (connectorId > 0) { reportData.push({ component: { - evse: { connectorId, id: 1 }, + evse: { connectorId: connectorId.toString(), id: 1 }, name: 'Connector', }, variable: { name: 'ConnectorType' }, - variableAttribute: [{ type: 'Actual', value: String(connector.connectorType) }], + variableAttribute: [ + { type: 'Actual', value: connector.type ?? ConnectorEnumType.Unknown }, + ], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, }) } @@ -369,7 +348,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { const stationInfo = chargingStation.stationInfo if (stationInfo.chargePointModel) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: 'ChargingStation' }, variable: { name: 'Model' }, variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointModel }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -377,7 +356,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { } if (stationInfo.chargePointVendor) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: 'ChargingStation' }, variable: { name: 'VendorName' }, variableAttribute: [{ type: 'Actual', value: stationInfo.chargePointVendor }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -385,7 +364,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { } if (stationInfo.firmwareVersion) { reportData.push({ - component: { name: OCPP20Constants.ComponentName.CHARGING_STATION }, + component: { name: 'ChargingStation' }, variable: { name: 'FirmwareVersion' }, variableAttribute: [{ type: 'Actual', value: stationInfo.firmwareVersion }], variableCharacteristics: { dataType: 'string', supportsMonitoring: false }, @@ -396,6 +375,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { default: logger.warn( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `${chargingStation.logPrefix()} ${moduleName}.buildReportData: Unknown reportBase '${reportBase}'` ) } @@ -403,6 +383,29 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { return reportData } + private handleRequestGetBaseReport ( + chargingStation: ChargingStation, + commandPayload: OCPP20GetBaseReportRequest + ): OCPP20GetBaseReportResponse { + logger.debug( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: GetBaseReport request received with requestId ${commandPayload.requestId} and reportBase ${commandPayload.reportBase}` + ) + // Build report data to check if any data is available + const reportData = this.buildReportData(chargingStation, commandPayload.reportBase) + if (reportData.length === 0) { + logger.info( + `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetBaseReport: No data available for reportBase ${commandPayload.reportBase}` + ) + return { + status: GenericDeviceModelStatusEnumType.EmptyResultSet, + } + } + return { + status: GenericDeviceModelStatusEnumType.Accepted, + } + } + private validatePayload ( chargingStation: ChargingStation, commandName: OCPP20IncomingRequestCommand, diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index 57eeaca6..926d4d17 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -119,7 +119,6 @@ export class OCPP20RequestService extends OCPPRequestService { return OCPP20Constants.OCPP_RESPONSE_EMPTY as unknown as Request case OCPP20RequestCommand.NOTIFY_REPORT: return { - generatedAt: new Date(), ...commandParams, } as unknown as Request case OCPP20RequestCommand.STATUS_NOTIFICATION: diff --git a/src/types/ConnectorStatus.ts b/src/types/ConnectorStatus.ts index b9fef35e..d77a8744 100644 --- a/src/types/ConnectorStatus.ts +++ b/src/types/ConnectorStatus.ts @@ -1,5 +1,6 @@ import type { SampledValueTemplate } from './MeasurandPerPhaseSampledValueTemplates.js' import type { ChargingProfile } from './ocpp/ChargingProfile.js' +import type { ConnectorEnumType } from './ocpp/ConnectorEnumType.js' import type { ConnectorStatusEnum } from './ocpp/ConnectorStatusEnum.js' import type { MeterValue } from './ocpp/MeterValues.js' import type { AvailabilityType } from './ocpp/Requests.js' @@ -25,4 +26,5 @@ export interface ConnectorStatus { transactionSetInterval?: NodeJS.Timeout transactionStart?: Date transactionStarted?: boolean + type?: ConnectorEnumType } diff --git a/src/types/index.ts b/src/types/index.ts index 64450bb5..1ab04353 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -148,8 +148,6 @@ export { ReportBaseEnumType, } from './ocpp/2.0/Common.js' export { - type ComponentType, - type EVSEType, type OCPP20BootNotificationRequest, type OCPP20ClearCacheRequest, type OCPP20GetBaseReportRequest, @@ -161,7 +159,6 @@ export { type ReportDataType, type VariableAttributeType, type VariableCharacteristicsType, - type VariableType, } from './ocpp/2.0/Requests.js' export type { OCPP20BootNotificationResponse, @@ -171,7 +168,7 @@ export type { OCPP20NotifyReportResponse, OCPP20StatusNotificationResponse, } from './ocpp/2.0/Responses.js' -export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js' +export { OCPP20ComponentName, OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js' export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode.js' export { type ChargingProfile, @@ -190,6 +187,7 @@ export { SupportedFeatureProfiles, VendorParametersKey, } from './ocpp/Configuration.js' +export { ConnectorEnumType } from './ocpp/ConnectorEnumType.js' export { ConnectorStatusEnum, type ConnectorStatusTransition } from './ocpp/ConnectorStatusEnum.js' export { ErrorType } from './ocpp/ErrorType.js' export { MessageType } from './ocpp/MessageType.js' diff --git a/src/types/ocpp/2.0/Common.ts b/src/types/ocpp/2.0/Common.ts index d1ed68ed..a8a058a6 100644 --- a/src/types/ocpp/2.0/Common.ts +++ b/src/types/ocpp/2.0/Common.ts @@ -40,6 +40,13 @@ export enum DeleteCertificateStatusEnumType { NotFound = 'NotFound', } +export enum GenericDeviceModelStatusEnumType { + Accepted = 'Accepted', + EmptyResultSet = 'EmptyResultSet', + NotSupported = 'NotSupported', + Rejected = 'Rejected', +} + export enum GetCertificateIdUseEnumType { CSMSRootCertificate = 'CSMSRootCertificate', ManufacturerRootCertificate = 'ManufacturerRootCertificate', @@ -53,13 +60,6 @@ export enum GetCertificateStatusEnumType { Failed = 'Failed', } -export enum GenericDeviceModelStatusEnumType { - Accepted = 'Accepted', - EmptyResultSet = 'EmptyResultSet', - NotSupported = 'NotSupported', - Rejected = 'Rejected', -} - export enum GetInstalledCertificateStatusEnumType { Accepted = 'Accepted', NotFound = 'NotFound', @@ -84,6 +84,31 @@ export enum InstallCertificateUseEnumType { V2GRootCertificate = 'V2GRootCertificate', } +export enum OCPP20ConnectorEnumType { + cCCS1 = 'cCCS1', + cCCS2 = 'cCCS2', + cG105 = 'cG105', + cTesla = 'cTesla', + cType1 = 'cType1', + cType2 = 'cType2', + Other1PhMax16A = 'Other1PhMax16A', + Other1PhOver16A = 'Other1PhOver16A', + Other3Ph = 'Other3Ph', + Pan = 'Pan', + s309_1P_16A = 's309-1P-16A', + s309_1P_32A = 's309-1P-32A', + s309_3P_16A = 's309-3P-16A', + s309_3P_32A = 's309-3P-32A', + sBS1361 = 'sBS1361', + sCEE_7_7 = 'sCEE-7-7', + sType2 = 'sType2', + sType3 = 'sType3', + Undetermined = 'Undetermined', + Unknown = 'Unknown', + wInductive = 'wInductive', + wResonant = 'wResonant', +} + export enum OCPP20ConnectorStatusEnumType { Available = 'Available', Faulted = 'Faulted', diff --git a/src/types/ocpp/2.0/Requests.ts b/src/types/ocpp/2.0/Requests.ts index 1c2fb339..e4edd597 100644 --- a/src/types/ocpp/2.0/Requests.ts +++ b/src/types/ocpp/2.0/Requests.ts @@ -6,7 +6,12 @@ import type { OCPP20ConnectorStatusEnumType, ReportBaseEnumType, } from './Common.js' -import type { OCPP20SetVariableDataType } from './Variables.js' +import type { + ChargingStationType, + ComponentType, + OCPP20SetVariableDataType, + VariableType, +} from './Variables.js' export enum OCPP20IncomingRequestCommand { CLEAR_CACHE = 'ClearCache', @@ -36,19 +41,19 @@ export interface OCPP20GetBaseReportRequest extends JsonObject { export type OCPP20HeartbeatRequest = EmptyObject +export interface OCPP20InstallCertificateRequest extends JsonObject { + certificate: string + certificateType: InstallCertificateUseEnumType +} + export interface OCPP20NotifyReportRequest extends JsonObject { generatedAt: Date - requestId: number reportData?: ReportDataType[] + requestId: number seqNo: number tbc?: boolean } -export interface OCPP20InstallCertificateRequest extends JsonObject { - certificate: string - certificateType: InstallCertificateUseEnumType -} - export interface OCPP20SetVariablesRequest extends JsonObject { setVariableData: OCPP20SetVariableDataType[] } @@ -60,19 +65,6 @@ export interface OCPP20StatusNotificationRequest extends JsonObject { timestamp: Date } -interface ChargingStationType extends JsonObject { - firmwareVersion?: string - model: string - modem?: ModemType - serialNumber?: string - vendorName: string -} - -interface ModemType extends JsonObject { - iccid?: string - imsi?: string -} - export interface ReportDataType extends JsonObject { component: ComponentType variable: VariableType @@ -80,17 +72,6 @@ export interface ReportDataType extends JsonObject { variableCharacteristics?: VariableCharacteristicsType } -export interface ComponentType extends JsonObject { - evse?: EVSEType - instance?: string - name: string -} - -export interface VariableType extends JsonObject { - instance?: string - name: string -} - export interface VariableAttributeType extends JsonObject { type?: string value?: string @@ -100,8 +81,3 @@ export interface VariableCharacteristicsType extends JsonObject { dataType: string supportsMonitoring: boolean } - -export interface EVSEType extends JsonObject { - connectorId?: number - id: number -} diff --git a/src/types/ocpp/2.0/Responses.ts b/src/types/ocpp/2.0/Responses.ts index 225c5aae..7f498367 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -30,13 +30,13 @@ export interface OCPP20HeartbeatResponse extends JsonObject { currentTime: Date } -export type OCPP20NotifyReportResponse = EmptyObject - export interface OCPP20InstallCertificateResponse extends JsonObject { status: InstallCertificateStatusEnumType statusInfo?: StatusInfoType } +export type OCPP20NotifyReportResponse = EmptyObject + export interface OCPP20SetVariablesResponse extends JsonObject { setVariableResult: OCPP20SetVariableResultType[] } diff --git a/src/types/ocpp/2.0/Variables.ts b/src/types/ocpp/2.0/Variables.ts index e31da220..02a52eee 100644 --- a/src/types/ocpp/2.0/Variables.ts +++ b/src/types/ocpp/2.0/Variables.ts @@ -1,6 +1,27 @@ import type { JsonObject } from '../../JsonType.js' import type { EVSEType, StatusInfoType } from './Common.js' +export enum OCPP20ComponentName { + AlignedDataCtrlr = 'AlignedDataCtrlr', + AuthCacheCtrlr = 'AuthCacheCtrlr', + AuthCtrlr = 'AuthCtrlr', + CHAdeMOCtrlr = 'CHAdeMOCtrlr', + ClockCtrlr = 'ClockCtrlr', + CustomizationCtrlr = 'CustomizationCtrlr', + DeviceDataCtrlr = 'DeviceDataCtrlr', + DisplayMessageCtrlr = 'DisplayMessageCtrlr', + ISO15118Ctrlr = 'ISO15118Ctrlr', + LocalAuthListCtrlr = 'LocalAuthListCtrlr', + MonitoringCtrlr = 'MonitoringCtrlr', + OCPPCommCtrlr = 'OCPPCommCtrlr', + ReservationCtrlr = 'ReservationCtrlr', + SampledDataCtrlr = 'SampledDataCtrlr', + SecurityCtrlr = 'SecurityCtrlr', + SmartChargingCtrlr = 'SmartChargingCtrlr', + TariffCostCtrlr = 'TariffCostCtrlr', + TxCtrlr = 'TxCtrlr', +} + export enum OCPP20OptionalVariableName { HeartbeatInterval = 'HeartbeatInterval', WebSocketPingInterval = 'WebSocketPingInterval', @@ -48,27 +69,6 @@ enum AttributeEnumType { Target = 'Target', } -enum OCPP20ComponentName { - AlignedDataCtrlr = 'AlignedDataCtrlr', - AuthCacheCtrlr = 'AuthCacheCtrlr', - AuthCtrlr = 'AuthCtrlr', - CHAdeMOCtrlr = 'CHAdeMOCtrlr', - ClockCtrlr = 'ClockCtrlr', - CustomizationCtrlr = 'CustomizationCtrlr', - DeviceDataCtrlr = 'DeviceDataCtrlr', - DisplayMessageCtrlr = 'DisplayMessageCtrlr', - ISO15118Ctrlr = 'ISO15118Ctrlr', - LocalAuthListCtrlr = 'LocalAuthListCtrlr', - MonitoringCtrlr = 'MonitoringCtrlr', - OCPPCommCtrlr = 'OCPPCommCtrlr', - ReservationCtrlr = 'ReservationCtrlr', - SampledDataCtrlr = 'SampledDataCtrlr', - SecurityCtrlr = 'SecurityCtrlr', - SmartChargingCtrlr = 'SmartChargingCtrlr', - TariffCostCtrlr = 'TariffCostCtrlr', - TxCtrlr = 'TxCtrlr', -} - enum SetVariableStatusEnumType { Accepted = 'Accepted', NotSupportedAttributeType = 'NotSupportedAttributeType', @@ -78,6 +78,20 @@ enum SetVariableStatusEnumType { UnknownVariable = 'UnknownVariable', } +export interface ChargingStationType extends JsonObject { + firmwareVersion?: string + model: string + modem?: ModemType + serialNumber?: string + vendorName: string +} + +export interface ComponentType extends JsonObject { + evse?: EVSEType + instance?: string + name: OCPP20ComponentName | string +} + export interface OCPP20ComponentVariableType extends JsonObject { component: ComponentType variable?: VariableType @@ -98,10 +112,14 @@ export interface OCPP20SetVariableResultType extends JsonObject { variable: VariableType } -interface ComponentType extends JsonObject { - evse?: EVSEType +export interface VariableType extends JsonObject { instance?: string - name: OCPP20ComponentName | string + name: VariableName +} + +interface ModemType extends JsonObject { + iccid?: string + imsi?: string } type VariableName = @@ -109,8 +127,3 @@ type VariableName = | OCPP20RequiredVariableName | OCPP20VendorVariableName | string - -interface VariableType extends JsonObject { - instance?: string - name: VariableName -} diff --git a/src/types/ocpp/ConnectorEnumType.ts b/src/types/ocpp/ConnectorEnumType.ts new file mode 100644 index 00000000..cc36ef56 --- /dev/null +++ b/src/types/ocpp/ConnectorEnumType.ts @@ -0,0 +1,7 @@ +import { OCPP20ConnectorEnumType } from './2.0/Common.js' + +export const ConnectorEnumType = { + ...OCPP20ConnectorEnumType, +} as const +// eslint-disable-next-line @typescript-eslint/no-redeclare +export type ConnectorEnumType = OCPP20ConnectorEnumType -- 2.43.0