Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix energyReset command issue #6561 #6564

Merged
merged 1 commit into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sonoff/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t tuya_dimmer_min_limit : 1; // bit 19 (v6.6.0.5) - SetOption69 - Limits Tuya dimmers to minimum of 10% (25) when enabled.
uint32_t energy_weekend : 1; // bit 20 (v6.6.0.8) - CMND_TARIFF
uint32_t dds2382_model : 1; // bit 21 (v6.6.0.14) - SetOption71 - Select different Modbus registers for Active Energy (#6531)
uint32_t spare22 : 1;
uint32_t hardware_energy_total : 1; // bit 22 (v6.6.0.15) - SetOption72 - Enable / Disable hardware energy total counter as reference (#6561)
uint32_t spare23 : 1;
uint32_t spare24 : 1;
uint32_t spare25 : 1;
Expand Down
2 changes: 1 addition & 1 deletion sonoff/xdrv_03_energy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void EnergyUpdateTotal(float value, bool kwh)
Energy.kWhtoday = (unsigned long)((value - Energy.start_energy) * multiplier);
}

if (Energy.total < (value - 0.01)){ // We subtract a little offset to avoid continuous updates
if (Energy.total < (value - 0.01) && Settings.flag3.hardware_energy_total){ // We subtract a little offset to avoid continuous updates
RtcSettings.energy_kWhtotal = (unsigned long)((value * multiplier) - Energy.kWhtoday_offset - Energy.kWhtoday);
Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal;
Energy.total = (float)(RtcSettings.energy_kWhtotal + Energy.kWhtoday_offset + Energy.kWhtoday) / 100000;
Expand Down