Add energy var update at power on next day

This commit is contained in:
Theo Arends 2023-01-03 12:24:34 +01:00
parent dfc01cd3a4
commit 3810b78ef8
1 changed files with 5 additions and 2 deletions

View File

@ -350,14 +350,17 @@ void Energy200ms(void)
if (RtcTime.valid) {
if (!Energy.kWhtoday_offset_init && (RtcTime.day_of_year == Settings->energy_kWhdoy)) {
Energy.kWhtoday_offset_init = true;
for (uint32_t i = 0; i < 3; i++) {
Energy.kWhtoday_offset[i] = Settings->energy_kWhtoday_ph[i];
// RtcSettings.energy_kWhtoday_ph[i] = 0;
}
Energy.kWhtoday_offset_init = true;
}
if (LocalTime() == Midnight()) {
if ((LocalTime() == Midnight()) || (RtcTime.day_of_year > Settings->energy_kWhdoy)) {
Energy.kWhtoday_offset_init = true;
Settings->energy_kWhdoy = RtcTime.day_of_year;
for (uint32_t i = 0; i < 3; i++) {
Settings->energy_kWhyesterday_ph[i] = RtcSettings.energy_kWhtoday_ph[i];