fix: readd safety check in charging station log prefix helper
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 4 Jan 2024 14:11:35 +0000 (15:11 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 4 Jan 2024 14:11:35 +0000 (15:11 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index a57b5bd46545057ddbbe28e3d29e0b2a781a9c9a..8029178b56bdf69ef1b9238407260ea7d3897ae2 100644 (file)
@@ -238,8 +238,12 @@ export class ChargingStation extends EventEmitter {
   }
 
   public logPrefix = (): string => {
-    if (isNotEmptyString(this.stationInfo?.chargingStationId)) {
-      return logPrefix(` ${this.stationInfo?.chargingStationId} |`)
+    if (
+      this instanceof ChargingStation &&
+      this.stationInfo != null &&
+      isNotEmptyString(this.stationInfo.chargingStationId)
+    ) {
+      return logPrefix(` ${this.stationInfo.chargingStationId} |`)
     }
     let stationTemplate: ChargingStationTemplate | undefined
     try {