mirror of https://github.com/arendst/Tasmota.git
Fix ENERGY.Period after midnight
ENERGY.Period incorrectly shows 0 for the first teleperiod after midnight
This commit is contained in:
parent
afb3fc19a0
commit
d21599b75c
|
@ -273,13 +273,14 @@ void Energy200ms(void)
|
||||||
|
|
||||||
RtcSettings.energy_kWhtotal += RtcSettings.energy_kWhtoday;
|
RtcSettings.energy_kWhtotal += RtcSettings.energy_kWhtoday;
|
||||||
Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal;
|
Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal;
|
||||||
|
|
||||||
|
Energy.period -= RtcSettings.energy_kWhtoday; // this becomes a large unsigned, effectively a negative for EnergyShow calculation
|
||||||
Energy.kWhtoday = 0;
|
Energy.kWhtoday = 0;
|
||||||
Energy.kWhtoday_offset = 0;
|
Energy.kWhtoday_offset = 0;
|
||||||
RtcSettings.energy_kWhtoday = 0;
|
RtcSettings.energy_kWhtoday = 0;
|
||||||
Energy.start_energy = 0;
|
Energy.start_energy = 0;
|
||||||
|
// Energy.kWhtoday_delta = 0; // dont zero this, we need to carry the remainder over to tomorrow
|
||||||
|
|
||||||
Energy.kWhtoday_delta = 0;
|
|
||||||
Energy.period = Energy.kWhtoday;
|
|
||||||
EnergyUpdateToday();
|
EnergyUpdateToday();
|
||||||
#if defined(USE_ENERGY_MARGIN_DETECTION) && defined(USE_ENERGY_POWER_LIMIT)
|
#if defined(USE_ENERGY_MARGIN_DETECTION) && defined(USE_ENERGY_POWER_LIMIT)
|
||||||
Energy.max_energy_state = 3;
|
Energy.max_energy_state = 3;
|
||||||
|
@ -1066,10 +1067,7 @@ void EnergyShow(bool json)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_energy_period) {
|
if (show_energy_period) {
|
||||||
float energy = 0;
|
float energy = (float)(RtcSettings.energy_kWhtoday - Energy.period) / 100;
|
||||||
if (Energy.period) {
|
|
||||||
energy = (float)(RtcSettings.energy_kWhtoday - Energy.period) / 100;
|
|
||||||
}
|
|
||||||
Energy.period = RtcSettings.energy_kWhtoday;
|
Energy.period = RtcSettings.energy_kWhtoday;
|
||||||
char energy_period_chr[FLOATSZ];
|
char energy_period_chr[FLOATSZ];
|
||||||
dtostrfd(energy, Settings.flag2.wattage_resolution, energy_period_chr);
|
dtostrfd(energy, Settings.flag2.wattage_resolution, energy_period_chr);
|
||||||
|
|
Loading…
Reference in New Issue