Merge pull request #6564 from pablozg/fixenergyreset

Fix energyReset command issue #6561
This commit is contained in:
Theo Arends 2019-10-06 11:32:40 +02:00 committed by GitHub
commit ec9fa4f430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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;