Check if RTC time is valid before energy sum

This commit is contained in:
pablozg 2019-09-20 14:37:55 +02:00
parent 254f3f3f6c
commit acf85db0da
1 changed files with 8 additions and 6 deletions

View File

@ -167,12 +167,14 @@ void EnergyUpdateToday(void)
Energy.daily = (float)(RtcSettings.energy_kWhtoday) / 100000;
Energy.total = (float)(RtcSettings.energy_kWhtotal + RtcSettings.energy_kWhtoday) / 100000;
if (EnergyTariff1Active()) { // Tarrif1 = Off-Peak
RtcSettings.energy_usage.usage1_kWhtotal += energy_diff;
RtcSettings.energy_usage.return1_kWhtotal += return_diff;
} else {
RtcSettings.energy_usage.usage2_kWhtotal += energy_diff;
RtcSettings.energy_usage.return2_kWhtotal += return_diff;
if (RtcTime.valid){
if (EnergyTariff1Active()) { // Tarrif1 = Off-Peak
RtcSettings.energy_usage.usage1_kWhtotal += energy_diff;
RtcSettings.energy_usage.return1_kWhtotal += return_diff;
} else {
RtcSettings.energy_usage.usage2_kWhtotal += energy_diff;
RtcSettings.energy_usage.return2_kWhtotal += return_diff;
}
}
}