From 0674971f2ec11abd3b29922578596abef839b913 Mon Sep 17 00:00:00 2001 From: pablozg Date: Fri, 4 Oct 2019 19:19:48 +0200 Subject: [PATCH] Fix energyReset command issue #6561 --- sonoff/settings.h | 2 +- sonoff/xdrv_03_energy.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sonoff/settings.h b/sonoff/settings.h index c2be9d6e3..938102cc6 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -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; diff --git a/sonoff/xdrv_03_energy.ino b/sonoff/xdrv_03_energy.ino index cd5cc0f45..c4285eaaf 100644 --- a/sonoff/xdrv_03_energy.ino +++ b/sonoff/xdrv_03_energy.ino @@ -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;