From 45c0ae82dee8cf065f6303c4853c8adfe239dee1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 2 Oct 2022 19:23:10 +0200 Subject: [PATCH] Set connector status at start given its availability first MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 38 ++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 05ef9252..7853d10e 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -535,19 +535,6 @@ export default class ChargingStation { if (this.stopping === false) { this.stopping = true; await this.stopMessageSequence(reason); - for (const connectorId of this.connectors.keys()) { - if (connectorId > 0) { - await this.ocppRequestService.requestHandler< - StatusNotificationRequest, - StatusNotificationResponse - >(this, RequestCommand.STATUS_NOTIFICATION, { - connectorId, - status: ChargePointStatus.UNAVAILABLE, - errorCode: ChargePointErrorCode.NO_ERROR, - }); - this.getConnectorStatus(connectorId).status = null; - } - } this.closeWSConnection(); this.wsConnectionRestarted = false; if (this.getEnableStatistics()) { @@ -1775,12 +1762,6 @@ export default class ChargingStation { let chargePointStatus: ChargePointStatus; if (connectorId === 0) { continue; - } else if ( - !this.getConnectorStatus(connectorId)?.status && - this.getConnectorStatus(connectorId)?.bootStatus - ) { - // Set boot status in template at startup - chargePointStatus = this.getConnectorStatus(connectorId).bootStatus; } else if ( !this.getConnectorStatus(connectorId)?.status && (this.isChargingStationAvailable() === false || @@ -1788,6 +1769,12 @@ export default class ChargingStation { this.isConnectorAvailable(connectorId) === false)) ) { chargePointStatus = ChargePointStatus.UNAVAILABLE; + } else if ( + !this.getConnectorStatus(connectorId)?.status && + this.getConnectorStatus(connectorId)?.bootStatus + ) { + // Set boot status in template at startup + chargePointStatus = this.getConnectorStatus(connectorId).bootStatus; } else if (this.getConnectorStatus(connectorId)?.status) { // Set previous status at startup chargePointStatus = this.getConnectorStatus(connectorId).status; @@ -1825,6 +1812,19 @@ export default class ChargingStation { } else { await this.stopRunningTransactions(reason); } + for (const connectorId of this.connectors.keys()) { + if (connectorId > 0) { + await this.ocppRequestService.requestHandler< + StatusNotificationRequest, + StatusNotificationResponse + >(this, RequestCommand.STATUS_NOTIFICATION, { + connectorId, + status: ChargePointStatus.UNAVAILABLE, + errorCode: ChargePointErrorCode.NO_ERROR, + }); + this.getConnectorStatus(connectorId).status = null; + } + } } private startWebSocketPing(): void { -- 2.34.1