refactor: factor out OCPP params handling helpers
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 2.0 / OCPP20ResponseService.ts
index 4984b115e48a03d0315a83eeee28ae2c74e488cf..81dca3a4a29a46de3c54d85ad3b3b2324ccccaf6 100644 (file)
@@ -3,7 +3,7 @@
 import type { JSONSchemaType } from 'ajv';
 
 import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
-import { type ChargingStation, ChargingStationConfigurationUtils } from '../../../charging-station';
+import { type ChargingStation, addConfigurationKey } from '../../../charging-station';
 import { OCPPError } from '../../../exception';
 import {
   ErrorType,
@@ -40,9 +40,15 @@ export class OCPP20ResponseService extends OCPPResponseService {
     // }
     super(OCPPVersion.VERSION_20);
     this.responseHandlers = new Map<OCPP20RequestCommand, ResponseHandler>([
-      [OCPP20RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)],
-      [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this)],
-      [OCPP20RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler.bind(this)],
+      [
+        OCPP20RequestCommand.BOOT_NOTIFICATION,
+        this.handleResponseBootNotification.bind(this) as ResponseHandler,
+      ],
+      [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this) as ResponseHandler],
+      [
+        OCPP20RequestCommand.STATUS_NOTIFICATION,
+        this.emptyResponseHandler.bind(this) as ResponseHandler,
+      ],
     ]);
     this.jsonSchemas = new Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>([
       [
@@ -162,7 +168,7 @@ export class OCPP20ResponseService extends OCPPResponseService {
     payload: OCPP20BootNotificationResponse,
   ): void {
     if (payload.status === RegistrationStatusEnumType.ACCEPTED) {
-      ChargingStationConfigurationUtils.addConfigurationKey(
+      addConfigurationKey(
         chargingStation,
         OCPP20OptionalVariableName.HeartbeatInterval,
         payload.interval.toString(),