Update the last seen only on Charging Station connection and not REST connection
MODIFY
src/server/ocpp/json/JsonRestWSConnection.ts
src/server/ocpp/json/JsonRestWSConnection.ts
@@ -25,9 +25,7 @@ export default class JsonRestWSConnection extends WSConnection {
if (!this.initialized) {
// Call super class
await super.initialize();
- // Ok
this.initialized = true;
- // Log
await Logging.logInfo({
tenantID: this.getTenantID(),
source: this.getChargingStationID(),

MODIFY
src/server/ocpp/json/JsonWSConnection.ts
src/server/ocpp/json/JsonWSConnection.ts
@@ -61,6 +61,18 @@ export default class JsonWSConnection extends WSConnection {
if (!this.initialized) {
// Call super class
await super.initialize();
+ // Update the Charging Station
+ const chargingStation = await ChargingStationStorage.getChargingStation(this.getTenantID(), this.getChargingStationID(), {}, ['id']);
+ if (chargingStation) {
+ // Update Last Seen
+ await ChargingStationStorage.saveChargingStationLastSeen(this.getTenantID(),
+ chargingStation.id, { lastSeen: new Date() });
+ // Update CF Instance
+ if (Configuration.isCloudFoundry()) {
+ await ChargingStationStorage.saveChargingStationCFApplicationIDAndInstanceIndex(
+ this.getTenantID(), chargingStation.id, Configuration.getCFApplicationIDAndInstanceIndex());
+ }
+ }
// Initialize the default Headers
this.headers = {
chargeBoxIdentity: this.getChargingStationID(),

MODIFY
src/server/ocpp/json/WSConnection.ts
src/server/ocpp/json/WSConnection.ts
@@ -123,18 +123,6 @@ export default abstract class WSConnection {
// Check Tenant?
await DatabaseUtils.checkTenant(this.tenantID);
this.validTenant = true;
- // Update the Charging Station
- const chargingStation = await ChargingStationStorage.getChargingStation(this.tenantID, this.getChargingStationID(), {}, ['id']);
- if (chargingStation) {
- // Update Last Seen
- await ChargingStationStorage.saveChargingStationLastSeen(this.getTenantID(),
- chargingStation.id, { lastSeen: new Date() });
- // Update CF Instance
- if (Configuration.isCloudFoundry()) {
- await ChargingStationStorage.saveChargingStationCFApplicationIDAndInstanceIndex(
- this.tenantID, chargingStation.id, Configuration.getCFApplicationIDAndInstanceIndex());
- }
- }
} catch (error) {
// Custom Error
await Logging.logException(error, ServerAction.WS_CONNECTION, this.getChargingStationID(), 'WSConnection', 'initialize', this.tenantID);

Update the last seen only on Charging Station connection and not REST connection