Update the grid import and export code

This commit is contained in:
atef 2024-03-08 14:09:30 +01:00
parent b5f8658300
commit d461249855
1 changed files with 8 additions and 7 deletions

View File

@ -69,7 +69,7 @@ public static class Aggregator
if (await dailyAggregatedData.PushToS3())
{
DeleteHourlyData("HourlyData",currentTime.ToUnixTime());
dailyAggregatedData.DeleteDailyData("DailyData");
AggregatedData.DeleteDailyData("DailyData");
}
}
@ -158,11 +158,12 @@ public static class Aggregator
}
break;
case "/GridMeter/ActivePowerExportT2":
case "/GridMeter/ActivePowerExportT3":
// we are using different register to check which value from the grid meter we need to use
// At the moment register 8002 amd 8012. in KWh
gridPowerExport.Add(value);
break;
case "/GridMeter/ActivePowerImportT2":
case "/GridMeter/ActivePowerImportT3":
gridPowerImport.Add(value);
break;
case "/Battery/HeatingPower":
@ -205,8 +206,8 @@ public static class Aggregator
var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0;
var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0;
var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max()/1000 : 0.0;
var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max()/1000 : 0.0;
var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max() - gridPowerExport.Min(): 0.0;
var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max() - gridPowerImport.Min(): 0.0;
var dSumPvPower = pvPowerSum.Any() ? pvPowerSum.Max() : 0.0;
@ -339,8 +340,8 @@ public static class Aggregator
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
DischargingBatteryPower = batteryDischargePower.Any() ? batteryDischargePower.Average(): 0.0,
ChargingBatteryPower = batteryChargePower.Any() ? batteryChargePower.Average() : 0.0,
GridExportPower = gridPowerExport.Any() ? gridPowerExport.Max() : 0.0,
GridImportPower = gridPowerImport.Any() ? gridPowerImport.Max() : 0.0,
GridExportPower = gridPowerExport.Any() ? gridPowerExport.Sum() : 0.0,
GridImportPower = gridPowerImport.Any() ? gridPowerImport.Sum() : 0.0,
PvPower = pvPower.Any() ? pvPower.Max() : 0.0,
HeatingPower = heatingPowerAvg.Any() ? heatingPowerAvg.Average() : 0.0,
};