Go though Sites to push EVSE Statuses to Hubject
MODIFY
src/client/oicp/CpoOICPClient.ts
src/client/oicp/CpoOICPClient.ts
@@ -386,12 +386,20 @@ export default class CpoOICPClient extends OICPClient {
};
// Get timestamp before starting process - to be saved in DB at the end of the process
const startDate = new Date();
+ let sites: Site[];
+ let currentSiteSkip = 0;
+ do {
+ // Get the public Sites
+ sites = (await SiteStorage.getSites(this.tenant.id,
+ { public: true }, { skip: currentSiteSkip, limit: Constants.DB_RECORD_COUNT_DEFAULT })).result;
+ if (!Utils.isEmptyArray(sites)) {
+ for (const site of sites) {
let chargingStations: ChargingStation[];
- let currentSkip = 0;
+ let currentChargingStationSkip = 0;
do {
// Get all charging stations from tenant
chargingStations = (await ChargingStationStorage.getChargingStations(this.tenant.id,
- { public: true }, { skip: currentSkip, limit: Constants.DB_RECORD_COUNT_DEFAULT })).result;
+ { siteIDs: [site.id], public: true }, { skip: currentChargingStationSkip, limit: Constants.DB_RECORD_COUNT_DEFAULT })).result;
if (!Utils.isEmptyArray(chargingStations)) {
// Convert (public) charging stations to OICP EVSE Statuses
const evseStatuses = OICPUtils.convertChargingStationsToEvseStatuses(chargingStations, options);
@@ -426,7 +434,7 @@ export default class CpoOICPClient extends OICPClient {
}
// Only one post request for multiple EVSE Statuses
result.total = evseStatusesToProcess.length;
- if (evseStatusesToProcess) {
+ if (!Utils.isEmptyArray(evseStatusesToProcess)) {
try {
await this.pushEvseStatus(evseStatusesToProcess, actionType);
result.success = result.total;
@@ -449,8 +457,12 @@ export default class CpoOICPClient extends OICPClient {
}
}
}
- currentSkip += Constants.DB_RECORD_COUNT_DEFAULT;
+ currentChargingStationSkip += Constants.DB_RECORD_COUNT_DEFAULT;
} while (!Utils.isEmptyArray(chargingStations));
+ }
+ }
+ currentSiteSkip += Constants.DB_RECORD_COUNT_DEFAULT;
+ } while (!Utils.isEmptyArray(sites));
// Save result in oicp endpoint
this.oicpEndpoint.lastPatchJobOn = startDate;
// Set result

Go though Sites to push EVSE Statuses to Hubject