Added last metric timestamp + renamed lastConsumptionWh to lastMetricWh + removed consumption filtered request for asset update
MODIFY
src/integration/asset/schneider/SchneiderAssetIntegration.ts
src/integration/asset/schneider/SchneiderAssetIntegration.ts
@@ -61,7 +61,7 @@ export default class SchneiderAssetIntegration extends AssetIntegration<AssetSet
let consumption = {} as AbstractConsumption;
// Convert data value to number and get consumption
consumption.consumptionWh = +data[0].Value * 1000;
- consumption.lastConsumptionWh = this.getLastConsumptionWh(asset, +data[0].Value)
+ consumption.lastMetricWh = this.getlastMetricWh(asset, +data[0].Value)
consumption.instantAmpsL1 = +data[6].Value;
consumption.instantAmpsL2 = +data[7].Value;
consumption.instantAmpsL3 = +data[8].Value;
@@ -74,6 +74,7 @@ export default class SchneiderAssetIntegration extends AssetIntegration<AssetSet
consumption.instantWattsL2 = +data[18].Value * 1000;
consumption.instantWattsL3 = +data[19].Value * 1000;
consumption.instantWatts = +data[20].Value * 1000;
+ consumption.lastMetric = new Date();
return consumption;
}
@@ -103,7 +104,7 @@ export default class SchneiderAssetIntegration extends AssetIntegration<AssetSet
return params;
}
- private getLastConsumptionWh(asset: Asset, consumptionkWh: number): number {
+ private getlastMetricWh(asset: Asset, consumptionkWh: number): number {
const consumptionWh = consumptionkWh * 1000;
if (asset.consumption && consumptionWh > asset.consumption.consumptionWh) {
return consumptionWh - asset.consumption.consumptionWh;

MODIFY
src/server/rest/service/security/AssetSecurity.ts
src/server/rest/service/security/AssetSecurity.ts
@@ -52,7 +52,6 @@ export default class AssetSecurity {
filteredRequest.assetType = sanitize(request.assetType),
filteredRequest.image = request.image;
filteredRequest.dynamicAsset = UtilsSecurity.filterBoolean(request.dynamicAsset);
- filteredRequest.consumption = UtilsSecurity.filterAbstractConsumptionRequest(request.consumption);
if (request.coordinates && request.coordinates.length === 2) {
filteredRequest.coordinates = [
sanitize(request.coordinates[0]),

MODIFY
src/server/rest/service/security/UtilsSecurity.ts
src/server/rest/service/security/UtilsSecurity.ts
@@ -105,27 +105,6 @@ export default class UtilsSecurity {
}
}
- static filterAbstractConsumptionRequest(consumption: AbstractConsumption): AbstractConsumption {
- const filteredConsumption: AbstractConsumption = {} as AbstractConsumption;
- if (consumption) {
- filteredConsumption.consumptionWh = sanitize(consumption.consumptionWh);
- filteredConsumption.instantAmpsL1 = sanitize(consumption.instantAmpsL1);
- filteredConsumption.instantAmpsL2 = sanitize(consumption.instantAmpsL2);
- filteredConsumption.instantAmpsL3 = sanitize(consumption.instantAmpsL3);
- filteredConsumption.instantAmps = sanitize(consumption.instantAmps);
- filteredConsumption.instantVoltsL1 = sanitize(consumption.instantVoltsL1);
- filteredConsumption.instantVoltsL2 = sanitize(consumption.instantVoltsL2)
- filteredConsumption.instantVoltsL3 = sanitize(consumption.instantVoltsL3);
- filteredConsumption.instantVolts = sanitize(consumption.instantVolts);
- filteredConsumption.instantWattsL1 = sanitize(consumption.instantWattsL1);
- filteredConsumption.instantWattsL2 = sanitize(consumption.instantWattsL2);
- filteredConsumption.instantWattsL3 = sanitize(consumption.instantWattsL3);
- filteredConsumption.instantWatts = sanitize(consumption.instantWatts);
- filteredConsumption.lastConsumptionWh = sanitize(consumption.lastConsumptionWh);
- }
- return filteredConsumption;
- }
-
static filterAddressRequest(address: Address): Address {
const filteredAddress: Address = {} as Address;
if (address) {

MODIFY
src/types/Consumption.ts
src/types/Consumption.ts
@@ -18,7 +18,8 @@ export interface AbstractConsumption {
instantVoltsDC: number;
consumptionWh: number;
consumptionAmps: number;
- lastConsumptionWh: number;
+ lastMetricWh: number;
+ lastMetric: Date;
}
export default interface Consumption extends AbstractConsumption {

Added last metric timestamp + renamed lastConsumptionWh to lastMetricWh + removed consumption filtered request for asset update