Assets - store state of charge in consumption and asset
MODIFY
src/integration/asset/greencom/GreencomAssetIntegration.ts
src/integration/asset/greencom/GreencomAssetIntegration.ts
@@ -78,6 +78,7 @@ export default class GreencomAssetIntegration extends AssetIntegration<AssetSett
case AssetType.CONSUMPTION_AND_PRODUCTION:
consumption.currentInstantWatts = data.power.charge.average - data.power.discharge.average;
consumption.currentConsumptionWh = data.energy.charge.sum - data.energy.discharge.sum;
+ consumption.currentStateOfCharge = data.percent?.soc?.current;
break;
}
}

MODIFY
src/scheduler/tasks/AssetGetConsumptionTask.ts
src/scheduler/tasks/AssetGetConsumptionTask.ts
@@ -49,6 +49,7 @@ export default class AssetGetConsumptionTask extends SchedulerTask {
cumulatedConsumptionAmps: Math.floor(assetConsumption.currentConsumptionWh / asset.siteArea.voltage),
instantAmps: assetConsumption.currentInstantAmps,
instantWatts: assetConsumption.currentInstantWatts,
+ stateOfCharge: assetConsumption.currentStateOfCharge,
};
// Set Consumption to Asset
this.assignAssetConsumption(asset, assetConsumption);
@@ -87,5 +88,6 @@ export default class AssetGetConsumptionTask extends SchedulerTask {
asset.currentInstantWattsL1 = consumption.currentInstantWattsL1;
asset.currentInstantWattsL2 = consumption.currentInstantWattsL2;
asset.currentInstantWattsL3 = consumption.currentInstantWattsL3;
+ asset.currentStateOfCharge = consumption.currentStateOfCharge;
}
}

MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -75,7 +75,7 @@ export default class AssetService {
assetID: filteredRequest.AssetID,
startDate: filteredRequest.StartDate,
endDate: filteredRequest.EndDate
- }, [ 'startedAt', 'instantWatts', 'instantAmps', 'limitWatts', 'limitAmps', 'endedAt' ]);
+ }, [ 'startedAt', 'instantWatts', 'instantAmps', 'limitWatts', 'limitAmps', 'endedAt', 'stateOfCharge' ]);
// Assign
asset.values = consumptions;
// Return
@@ -192,6 +192,7 @@ export default class AssetService {
asset.currentInstantWattsL1 = consumption.currentInstantWattsL1;
asset.currentInstantWattsL2 = consumption.currentInstantWattsL2;
asset.currentInstantWattsL3 = consumption.currentInstantWattsL3;
+ asset.currentStateOfCharge = consumption.currentStateOfCharge;
// Save Asset
await AssetStorage.saveAsset(req.user.tenantID, asset);
// Ok
@@ -352,7 +353,7 @@ export default class AssetService {
{ limit: filteredRequest.Limit, skip: filteredRequest.Skip, sort: filteredRequest.Sort, onlyRecordCount: filteredRequest.OnlyRecordCount },
[
'id', 'name', 'siteAreaID', 'siteArea.id', 'siteArea.name', 'siteArea.siteID', 'assetType', 'coordinates',
- 'dynamicAsset', 'connectionID', 'meterID', 'currentInstantWatts'
+ 'dynamicAsset', 'connectionID', 'meterID', 'currentInstantWatts', 'currentStateOfCharge'
]
);
res.json(assets);

MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -70,6 +70,7 @@ export default class AssetStorage {
currentInstantWattsL1: Utils.convertToFloat(assetToSave.currentInstantWattsL1),
currentInstantWattsL2: Utils.convertToFloat(assetToSave.currentInstantWattsL2),
currentInstantWattsL3: Utils.convertToFloat(assetToSave.currentInstantWattsL3),
+ currentStateOfCharge: Utils.convertToFloat(assetToSave.currentStateOfCharge),
};
if (assetToSave.lastConsumption) {
assetMDB.lastConsumption = {

MODIFY
src/storage/mongodb/ConsumptionStorage.ts
src/storage/mongodb/ConsumptionStorage.ts
@@ -142,7 +142,8 @@ export default class ConsumptionStorage {
instantWatts: { $sum: '$instantWatts' },
instantAmps: { $sum: '$instantAmps' },
limitWatts: { $last: '$limitSiteAreaWatts' },
- limitAmps: { $last: '$limitSiteAreaAmps' }
+ limitAmps: { $last: '$limitSiteAreaAmps' },
+ stateOfCharge: { $last: '$stateOfCharge' },
}
});
// Rebuild the date

MODIFY
src/types/Consumption.ts
src/types/Consumption.ts
@@ -21,6 +21,7 @@ export interface AbstractCurrentConsumption {
currentInstantAmpsL2?: number;
currentInstantAmpsL3?: number;
currentInstantAmpsDC?: number;
+ currentStateOfCharge?: number;
}
export interface AbstractConsumption {

Assets - store state of charge in consumption and asset