From a1a6953521b3e1b51452d38b1d173dc273b18deb Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Thu, 23 May 2024 20:21:56 +0200 Subject: [PATCH] Use export price for export cost calculations --- lib/EnergyAccounting/src/EnergyAccounting.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/EnergyAccounting/src/EnergyAccounting.cpp b/lib/EnergyAccounting/src/EnergyAccounting.cpp index e1bec18a..8b1b1ef2 100644 --- a/lib/EnergyAccounting/src/EnergyAccounting.cpp +++ b/lib/EnergyAccounting/src/EnergyAccounting.cpp @@ -82,8 +82,8 @@ bool EnergyAccounting::update(AmsData* amsData) { init = true; } - float price = getPriceForHour(PRICE_DIRECTION_IMPORT, 0); - if(!initPrice && price != PRICE_NO_VALUE) { + float importPrice = getPriceForHour(PRICE_DIRECTION_IMPORT, 0); + if(!initPrice && importPrice != PRICE_NO_VALUE) { calcDayCost(); } @@ -155,8 +155,8 @@ bool EnergyAccounting::update(AmsData* amsData) { float kwhi = (amsData->getActiveImportPower() * (((float) ms) / 3600000.0)) / 1000.0; if(kwhi > 0) { this->realtimeData->use += kwhi; - if(price != PRICE_NO_VALUE) { - float cost = price * kwhi; + if(importPrice != PRICE_NO_VALUE) { + float cost = importPrice * kwhi; this->realtimeData->costHour += cost; this->realtimeData->costDay += cost; } @@ -169,8 +169,9 @@ bool EnergyAccounting::update(AmsData* amsData) { float kwhe = (amsData->getActiveExportPower() * (((float) ms) / 3600000.0)) / 1000.0; if(kwhe > 0) { this->realtimeData->produce += kwhe; - if(price != PRICE_NO_VALUE) { - float income = price * kwhe; + float exportPrice = getPriceForHour(PRICE_DIRECTION_EXPORT, 0); + if(exportPrice != PRICE_NO_VALUE) { + float income = exportPrice * kwhe; this->realtimeData->incomeHour += income; this->realtimeData->incomeDay += income; }