Fix MeterValues JSON payload
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Aug 2021 18:43:30 +0000 (20:43 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Aug 2021 18:43:30 +0000 (20:43 +0200)
Close https://github.com/sap-labs-france/ev-simulator/issues/17

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/types/ocpp/1.6/MeterValues.ts

index dcd38a817a1bbb9465a87fe62868e393186b1579..8bdc37cf8bf8415d2d3bc31a69b575d573e450a9 100644 (file)
@@ -332,7 +332,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
       const payload: MeterValuesRequest = {
         connectorId,
         transactionId,
-        meterValue,
+        meterValue: [meterValue],
       };
       await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.METER_VALUES);
     } catch (error) {
@@ -345,7 +345,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
       const payload: MeterValuesRequest = {
         connectorId,
         transactionId,
-        meterValue: beginMeterValue,
+        meterValue: [beginMeterValue],
       };
       await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.METER_VALUES);
     } catch (error) {
@@ -358,7 +358,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
       const payload: MeterValuesRequest = {
         connectorId,
         transactionId,
-        meterValue: endMeterValue,
+        meterValue: [endMeterValue],
       };
       await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.METER_VALUES);
     } catch (error) {
index 2f0695389e731c27847b3edd0074f5df00aa8c67..ec200b19f279bf68ba760b5e00065cd663364884 100644 (file)
@@ -97,7 +97,7 @@ export interface OCPP16MeterValue {
 export interface MeterValuesRequest {
   connectorId: number;
   transactionId?: number;
-  meterValue: OCPP16MeterValue | OCPP16MeterValue[];
+  meterValue: OCPP16MeterValue[];
 }
 
 // eslint-disable-next-line @typescript-eslint/no-empty-interface