Handle charger with no OCPP params
MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
-import { ChargingProfile, ChargingProfilePurposeType, ChargingRateUnitType } from '../../types/ChargingProfile';
-import ChargingStation, { ChargePoint, ChargingStationOcppParameters, ChargingStationTemplate, Connector, ConnectorType, OcppParameter } from '../../types/ChargingStation';
-import { ChargingStationInError, ChargingStationInErrorType } from '../../types/InError';
+import fs from 'fs';
+
+import moment from 'moment';
import { GridFSBucket, GridFSBucketReadStream } from 'mongodb';
import BackendError from '../../exception/BackendError';
-import Constants from '../../utils/Constants';
-import Cypher from '../../utils/Cypher';
-import { DataResult } from '../../types/DataResult';
-import DatabaseUtils from './DatabaseUtils';
+import { ChargingProfile, ChargingProfilePurposeType, ChargingRateUnitType } from '../../types/ChargingProfile';
+import ChargingStation, { ChargePoint, ChargingStationOcppParameters, ChargingStationTemplate, Connector, ConnectorType, OcppParameter } from '../../types/ChargingStation';
import DbParams from '../../types/database/DbParams';
-import Logging from '../../utils/Logging';
+import { DataResult } from '../../types/DataResult';
+import global from '../../types/GlobalType';
+import { ChargingStationInError, ChargingStationInErrorType } from '../../types/InError';
import { OCPPFirmwareStatus } from '../../types/ocpp/OCPPServer';
import { ServerAction } from '../../types/Server';
import TenantComponents from '../../types/TenantComponents';
-import TenantStorage from './TenantStorage';
+import Constants from '../../utils/Constants';
+import Cypher from '../../utils/Cypher';
+import Logging from '../../utils/Logging';
import Utils from '../../utils/Utils';
-import fs from 'fs';
-import global from '../../types/GlobalType';
-import moment from 'moment';
+import DatabaseUtils from './DatabaseUtils';
+import TenantStorage from './TenantStorage';
const MODULE_NAME = 'ChargingStationStorage';
@@ -602,6 +603,7 @@ export default class ChargingStationStorage {
// Read DB
const parametersMDB = await global.database.getCollection<ChargingStationOcppParameters>(tenantID, 'configurations')
.findOne({ '_id': id });
+ if (parametersMDB) {
// Sort
if (parametersMDB.configuration) {
parametersMDB.configuration.sort((param1, param2) => {
@@ -621,6 +623,12 @@ export default class ChargingStationStorage {
result: parametersMDB.configuration
};
}
+ // No conf
+ return {
+ count: 0,
+ result: []
+ };
+ }
public static async getChargingProfile(tenantID: string, id: string): Promise<ChargingProfile> {
// Debug

Handle charger with no OCPP params