Add template section to list OCPP commands supported (#129)
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16ResponseService.ts
index fd972b261b6cc6e7e1334462534f8c0a19161390..47021ca6014f8f90c4488b72e9591f19b29afadf 100644 (file)
@@ -34,6 +34,7 @@ import logger from '../../../utils/Logger';
 import Utils from '../../../utils/Utils';
 import type ChargingStation from '../../ChargingStation';
 import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
+import { ChargingStationUtils } from '../../ChargingStationUtils';
 import OCPPResponseService from '../OCPPResponseService';
 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
 
@@ -65,7 +66,10 @@ export default class OCPP16ResponseService extends OCPPResponseService {
     requestPayload: JsonType
   ): Promise<void> {
     if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) {
-      if (this.responseHandlers.has(commandName)) {
+      if (
+        this.responseHandlers.has(commandName) &&
+        ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
+      ) {
         try {
           await this.responseHandlers.get(commandName)(chargingStation, payload, requestPayload);
         } catch (error) {
@@ -81,7 +85,8 @@ export default class OCPP16ResponseService extends OCPPResponseService {
             null,
             2
           )}`,
-          commandName
+          commandName,
+          payload
         );
       }
     } else {
@@ -92,7 +97,8 @@ export default class OCPP16ResponseService extends OCPPResponseService {
           null,
           2
         )} while the charging station is not registered on the central server. `,
-        commandName
+        commandName,
+        payload
       );
     }
   }
@@ -311,7 +317,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
         >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
           connectorId,
           transactionId: payload.transactionId,
-          meterValue: chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
+          meterValue: [chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue],
         }));
       await chargingStation.ocppRequestService.requestHandler<
         OCPP16StatusNotificationRequest,
@@ -407,11 +413,13 @@ export default class OCPP16ResponseService extends OCPPResponseService {
         >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
           connectorId: transactionConnectorId,
           transactionId: requestPayload.transactionId,
-          meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue(
-            chargingStation,
-            transactionConnectorId,
-            requestPayload.meterStop
-          ),
+          meterValue: [
+            OCPP16ServiceUtils.buildTransactionEndMeterValue(
+              chargingStation,
+              transactionConnectorId,
+              requestPayload.meterStop
+            ),
+          ],
         }));
       if (
         !chargingStation.isChargingStationAvailable() ||