Skip to content

Commit f216590

Browse files
Fix energy total non-monotonicity. (#24184)
1 parent 7036057 commit f216590

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ void Energy200ms(void) {
422422
Settings->energy_kWhexport_ph[i] = RtcSettings.energy_kWhexport_ph[i];
423423

424424
Energy->period[i] -= RtcSettings.energy_kWhtoday_ph[i]; // this becomes a large unsigned, effectively a negative for EnergyShow calculation
425-
Energy->kWhtoday[i] = 0;
425+
Energy->kWhtoday[i] = Energy->kWhtoday[i] % 100; // Roll fractional watt-hours into the next day since kWhtotal truncates to watt-hours.
426426
Energy->kWhtoday_offset[i] = 0;
427-
RtcSettings.energy_kWhtoday_ph[i] = 0;
427+
RtcSettings.energy_kWhtoday_ph[i] = Energy->kWhtoday[i];
428428
Settings->energy_kWhtoday_ph[i] = 0;
429429

430430
Energy->start_energy[i] = 0;

0 commit comments

Comments
 (0)