Fixed NPE

This commit is contained in:
Gunnar Skjold
2023-05-22 12:51:26 +02:00
parent a57405a7a5
commit 9d902c63de
3 changed files with 9 additions and 11 deletions

View File

@@ -577,6 +577,11 @@ bool AmsDataStorage::isHappy() {
}
bool AmsDataStorage::isDayHappy() {
if(tz == NULL) {
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Timezone is missing\n"));
return false;
}
time_t now = time(nullptr);
if(now < FirmwareVersion::BuildEpoch) return false;

View File

@@ -179,6 +179,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
void EnergyAccounting::calcDayCost() {
time_t now = time(nullptr);
tmElements_t local, utc;
if(tz == NULL) return;
breakTime(tz->toLocal(now), local);
if(getPriceForHour(0) != ENTSOE_NO_VALUE) {
@@ -205,10 +206,10 @@ float EnergyAccounting::getUseThisHour() {
}
float EnergyAccounting::getUseToday() {
if(tz == NULL) return 0.0;
float ret = 0.0;
time_t now = time(nullptr);
if(now < FirmwareVersion::BuildEpoch) return 0.0;
if(tz == NULL) return 0.0;
tmElements_t utc, local;
breakTime(tz->toLocal(now), local);
for(uint8_t i = 0; i < currentHour; i++) {
@@ -237,6 +238,7 @@ float EnergyAccounting::getProducedThisHour() {
}
float EnergyAccounting::getProducedToday() {
if(tz == NULL) return 0.0;
float ret = 0.0;
time_t now = time(nullptr);
if(now < FirmwareVersion::BuildEpoch) return 0.0;