Save the lastSeen fix only when charger is known
MODIFY
src/server/ocpp/json/JsonWSConnection.ts
src/server/ocpp/json/JsonWSConnection.ts
@@ -162,9 +162,13 @@ export default class JsonWSConnection extends WSConnection {
}
private async updateChargingStationLastSeen(): Promise<void> {
- await ChargingStationStorage.saveChargingStationLastSeen(this.getTenantID(), this.getChargingStationID(), {
+ const chargingStation = await ChargingStationStorage.getChargingStation(this.getTenantID(), this.getChargingStationID(), { issuer: true });
+ if (chargingStation) {
+ await ChargingStationStorage.saveChargingStationLastSeen(this.getTenantID(), this.getChargingStationID(),
+ {
lastSeen: new Date()
});
}
}
+}

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -133,7 +133,7 @@ export default class ChargingStationStorage {
}
public static async getChargingStation(tenantID: string, id: string = Constants.UNKNOWN_STRING_ID,
- params: { includeDeleted?: boolean } = {}, projectFields?: string[]): Promise<ChargingStation> {
+ params: { includeDeleted?: boolean, issuer?: boolean; } = {}, projectFields?: string[]): Promise<ChargingStation> {
const chargingStationsMDB = await ChargingStationStorage.getChargingStations(tenantID, {
chargingStationIDs: [id],
withSite: true, ...params

Save the lastSeen fix only when charger is known