refactor: factor out feature profile test
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStationUtils.ts
index 6c2732460c8cbd84c388ce58958f2d8f7f231657..2be30929d9107c2c416498c1ce3cc6f632524b27 100644 (file)
@@ -19,6 +19,7 @@ import {
 } from 'date-fns';
 
 import type { ChargingStation } from './ChargingStation';
+import { getConfigurationKey } from './ChargingStationConfigurationUtils';
 import { BaseError } from '../exception';
 import {
   AmpereUnits,
@@ -41,6 +42,8 @@ import {
   type OCPP20BootNotificationRequest,
   OCPPVersion,
   RecurrencyKindType,
+  StandardParametersKey,
+  SupportedFeatureProfiles,
   Voltage,
 } from '../types';
 import {
@@ -449,6 +452,16 @@ export const propagateSerialNumber = (
     : stationInfoDst?.meterSerialNumber && delete stationInfoDst.meterSerialNumber;
 };
 
+export const hasFeatureProfile = (
+  chargingStation: ChargingStation,
+  featureProfile: SupportedFeatureProfiles,
+): boolean | undefined => {
+  return getConfigurationKey(
+    chargingStation,
+    StandardParametersKey.SupportedFeatureProfiles,
+  )?.value?.includes(featureProfile);
+};
+
 export const getAmperageLimitationUnitDivider = (stationInfo: ChargingStationInfo): number => {
   let unitDivider = 1;
   switch (stationInfo.amperageLimitationUnit) {