From 1fdb60b661afed4d26796cb0a2ed15e78f3b40a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 31 Jan 2024 11:06:38 +0100 Subject: [PATCH] feat: expose template name used in stationInfo 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 | 7 ++++++- src/types/ChargingStationInfo.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 5c3c13c7..aa68abdf 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -3,7 +3,7 @@ import { createHash } from 'node:crypto' import { EventEmitter } from 'node:events' import { type FSWatcher, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs' -import { dirname, join } from 'node:path' +import { dirname, join, parse } from 'node:path' import { URL } from 'node:url' import { parentPort } from 'node:worker_threads' @@ -1126,6 +1126,7 @@ export class ChargingStation extends EventEmitter { } const stationInfo = stationTemplateToStationInfo(stationTemplate) stationInfo.hashId = getHashId(this.index, stationTemplate) + stationInfo.templateName = parse(this.templateFile).name stationInfo.chargingStationId = getChargingStationId(this.index, stationTemplate) stationInfo.ocppVersion = stationTemplate.ocppVersion ?? OCPPVersion.VERSION_16 createSerialNumber(stationTemplate, stationInfo) @@ -1180,6 +1181,10 @@ export class ChargingStation extends EventEmitter { stationInfo = this.getConfigurationFromFile()?.stationInfo if (stationInfo != null) { delete stationInfo.infoHash + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (stationInfo.templateName == null) { + stationInfo.templateName = parse(this.templateFile).name + } } } return stationInfo diff --git a/src/types/ChargingStationInfo.ts b/src/types/ChargingStationInfo.ts index 0f4fe97d..d4e4f8db 100644 --- a/src/types/ChargingStationInfo.ts +++ b/src/types/ChargingStationInfo.ts @@ -14,6 +14,7 @@ ChargingStationTemplate, | 'meterSerialNumberPrefix' > & { hashId: string + templateName: string /** @deprecated Use hashId instead */ infoHash?: string chargingStationId?: string -- 2.34.1