Skip to content

Commit

Permalink
Merge pull request #6564 from pablozg/fixenergyreset
Browse files Browse the repository at this point in the history
Fix energyReset command issue #6561
  • Loading branch information
arendst committed Oct 6, 2019
2 parents 853e090 + 0674971 commit ec9fa4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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

0 comments on commit ec9fa4f

Please sign in to comment.