return new URL(
`${
this.getSupervisionUrlOcppConfiguration() &&
- Utils.isNotEmptyString(this.getSupervisionUrlOcppKey())
+ Utils.isNotEmptyString(this.getSupervisionUrlOcppKey()) &&
+ Utils.isNotEmptyString(
+ ChargingStationConfigurationUtils.getConfigurationKey(
+ this,
+ this.getSupervisionUrlOcppKey()
+ )?.value
+ )
? ChargingStationConfigurationUtils.getConfigurationKey(
this,
this.getSupervisionUrlOcppKey()
- )?.value
+ ).value
: this.configuredSupervisionUrl.href
}/${this.stationInfo.chargingStationId}`
);
}
private getConfiguredSupervisionUrl(): URL {
+ let configuredSupervisionUrl: string;
const supervisionUrls = this.stationInfo?.supervisionUrls ?? Configuration.getSupervisionUrls();
if (Utils.isNotEmptyArray(supervisionUrls)) {
let configuredSupervisionUrlIndex: number;
configuredSupervisionUrlIndex = (this.index - 1) % supervisionUrls.length;
break;
}
- return new URL(supervisionUrls[configuredSupervisionUrlIndex]);
+ configuredSupervisionUrl = supervisionUrls[configuredSupervisionUrlIndex];
+ } else {
+ configuredSupervisionUrl = supervisionUrls as string;
+ }
+ if (Utils.isNotEmptyString(configuredSupervisionUrl)) {
+ return new URL(configuredSupervisionUrl);
}
- return new URL(supervisionUrls as string);
+ throw new BaseError('No supervision urls configured');
}
private stopHeartbeat(): void {