Fixed segfault when enabling verbose debug with fixed price

This commit is contained in:
Gunnar Skjold
2023-05-02 10:20:54 +02:00
parent d729d0c5bd
commit eea1782280
3 changed files with 8 additions and 6 deletions

View File

@@ -132,7 +132,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
use += kwhi;
if(price != ENTSOE_NO_VALUE) {
float cost = price * kwhi;
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), cost / 100.0, eapi->getCurrency());
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), cost / 100.0, currency.c_str());
costHour += cost;
costDay += cost;
}
@@ -142,7 +142,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
produce += kwhe;
if(price != ENTSOE_NO_VALUE) {
float income = price * kwhe;
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), income / 100.0, eapi->getCurrency());
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), income / 100.0, currency.c_str());
incomeHour += income;
incomeDay += income;
}
@@ -499,8 +499,9 @@ bool EnergyAccounting::updateMax(uint16_t val, uint8_t day) {
return false;
}
void EnergyAccounting::setFixedPrice(float price) {
void EnergyAccounting::setFixedPrice(float price, String currency) {
this->fixedPrice = price;
this->currency = currency;
}
float EnergyAccounting::getPriceForHour(uint8_t h) {