refactor: cleanup log messages
[e-mobility-charging-stations-simulator.git] / src / charging-station / broadcast-channel / ChargingStationWorkerBroadcastChannel.ts
index c9c2d84a512bfefacc2d944d1c086851ed83c3f7..422c964bcbedd232d28f1a7005efc09c7e5e989b 100644 (file)
@@ -15,6 +15,7 @@ import {
   DataTransferStatus,
   type DiagnosticsStatusNotificationRequest,
   type DiagnosticsStatusNotificationResponse,
+  type EmptyObject,
   type FirmwareStatusNotificationRequest,
   type FirmwareStatusNotificationResponse,
   type HeartbeatRequest,
@@ -36,17 +37,17 @@ import {
 } from '../../types';
 import { Constants, convertToInt, isEmptyObject, isNullOrUndefined, logger } from '../../utils';
 import type { ChargingStation } from '../ChargingStation';
-import { ChargingStationConfigurationUtils } from '../ChargingStationConfigurationUtils';
+import { getConfigurationKey } from '../ChargingStationConfigurationUtils';
 import { OCPP16ServiceUtils } from '../ocpp';
 
 const moduleName = 'ChargingStationWorkerBroadcastChannel';
 
 type CommandResponse =
+  | EmptyObject
   | StartTransactionResponse
   | StopTransactionResponse
   | AuthorizeResponse
   | BootNotificationResponse
-  | StatusNotificationResponse
   | HeartbeatResponse
   | DataTransferResponse;
 
@@ -173,11 +174,10 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
       [
         BroadcastChannelProcedureName.METER_VALUES,
         async (requestPayload?: BroadcastChannelRequestPayload) => {
-          const configuredMeterValueSampleInterval =
-            ChargingStationConfigurationUtils.getConfigurationKey(
-              chargingStation,
-              StandardParametersKey.MeterValueSampleInterval,
-            );
+          const configuredMeterValueSampleInterval = getConfigurationKey(
+            chargingStation,
+            StandardParametersKey.MeterValueSampleInterval,
+          );
           return this.chargingStation.ocppRequestService.requestHandler<
             MeterValuesRequest,
             MeterValuesResponse
@@ -239,8 +239,8 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
       ],
     ]);
     this.chargingStation = chargingStation;
-    this.onmessage = this.requestHandler.bind(this) as (message: MessageEvent) => void;
-    this.onmessageerror = this.messageErrorHandler.bind(this) as (message: MessageEvent) => void;
+    this.onmessage = this.requestHandler.bind(this) as (message: unknown) => void;
+    this.onmessageerror = this.messageErrorHandler.bind(this) as (message: unknown) => void;
   }
 
   private async requestHandler(messageEvent: MessageEvent): Promise<void> {
@@ -253,12 +253,12 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
     }
     const [uuid, command, requestPayload] = validatedMessageEvent.data as BroadcastChannelRequest;
     if (
-      !isNullOrUndefined(requestPayload?.hashIds) &&
-      requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false
+      !isNullOrUndefined(requestPayload.hashIds) &&
+      requestPayload.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false
     ) {
       return;
     }
-    if (!isNullOrUndefined(requestPayload?.hashId)) {
+    if (!isNullOrUndefined(requestPayload.hashId)) {
       logger.error(
         `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' array instead`,
       );