Load data before restoring from config file

This commit is contained in:
Gunnar Skjold 2023-04-05 07:54:59 +02:00
parent c1ca3d0c65
commit 68bbfd6527
2 changed files with 6 additions and 5 deletions

View File

@ -68,7 +68,8 @@ bool EnergyAccounting::update(AmsData* amsData) {
init = true;
}
if(!initPrice && eapi != NULL && getPriceForHour(0) != ENTSOE_NO_VALUE) {
float price = getPriceForHour(0);
if(!initPrice && eapi != NULL && price != ENTSOE_NO_VALUE) {
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing prices at %lu\n", (int32_t) now);
calcDayCost();
}
@ -129,8 +130,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
if(kwhi > 0) {
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) Adding %.4f kWh import\n", kwhi);
use += kwhi;
if(getPriceForHour(0) != ENTSOE_NO_VALUE) {
float price = getPriceForHour(0);
if(price != ENTSOE_NO_VALUE) {
float cost = price * kwhi;
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) and %.4f %s\n", cost / 100.0, eapi->getCurrency());
costHour += cost;
@ -140,8 +140,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
if(kwhe > 0) {
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) Adding %.4f kWh export\n", kwhe);
produce += kwhe;
if(getPriceForHour(0) != ENTSOE_NO_VALUE) {
float price = getPriceForHour(0);
if(price != ENTSOE_NO_VALUE) {
float income = price * kwhe;
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) and %.4f %s\n", income / 100.0, eapi->getCurrency());
incomeHour += income;

View File

@ -1521,6 +1521,8 @@ void configFileParse() {
bool sEa = false;
bool sDs = false;
ds.load();
SystemConfig sys;
WiFiConfig wifi;
MqttConfig mqtt;