Separate OCPP command support check implementation per type
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16RequestService.ts
index 1c98bc37d4c6b25f2b897f07aea86fa0414014ab..aa0ca4f16bf5a7230364e9ceb2b025f8ebbf240b 100644 (file)
@@ -29,10 +29,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
     commandParams?: JsonType,
     params?: RequestParams
   ): Promise<Response> {
-    if (
-      Object.values(OCPP16RequestCommand).includes(commandName) &&
-      ChargingStationUtils.isCommandSupported(commandName, chargingStation)
-    ) {
+    if (ChargingStationUtils.isRequestCommandSupported(commandName, chargingStation)) {
       return (await this.sendMessage(
         chargingStation,
         Utils.generateUUID(),
@@ -43,7 +40,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
     }
     throw new OCPPError(
       ErrorType.NOT_SUPPORTED,
-      `${moduleName}.requestHandler: Unsupported OCPP command ${commandName}`,
+      `${moduleName}.requestHandler: Unsupported OCPP command '${commandName}'`,
       commandName,
       commandParams
     );
@@ -148,7 +145,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
         throw new OCPPError(
           ErrorType.NOT_SUPPORTED,
           // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-          `${moduleName}.buildRequestPayload: Unsupported OCPP command: ${commandName}`,
+          `${moduleName}.buildRequestPayload: Unsupported OCPP command '${commandName}'`,
           commandName,
           commandParams
         );