From 86979646fff377a0acfdd88b1c7e1d202f97a5a6 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 11 May 2023 18:10:52 +0200 Subject: [PATCH] Energy power delta report delayed Energy power delta report delayed by two seconds allowing hardware to stabilize (#17751) --- CHANGELOG.md | 2 ++ RELEASENOTES.md | 6 +++++- tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino | 10 +++++++++- tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino | 10 +++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 510561e5c..a1e19d50e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ All notable changes to this project will be documented in this file. ### Changed - ESP32 Framework (Core) from v2.0.8 to v2.0.9 - autoconf extract `display.ini` to file system +- IRremoteESP8266 library from v2.8.4 to v2.8.5 +- Energy power delta report delayed by two seconds allowing hardware to stabilize (#17751) ### Fixed - Partition_Manager.tapp fixed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2490b7a56..9cc1ffd2b 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -127,10 +127,14 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Change command ``FileUpload`` index binary data detection from >199 to >299 ### Changed +- IRremoteESP8266 library from v2.8.4 to v2.8.5 - ESP32 Framework (Core) from v2.0.7 to v2.0.9 - Refactored Zero Cross Dimmer [#18481](https://github.com/arendst/Tasmota/issues/18481) +- Energy power delta report delayed by two seconds allowing hardware to stabilize [#17751](https://github.com/arendst/Tasmota/issues/17751) ### Fixed - ESP8266 Energy Export Active no update regression from v12.3.1.3 - NovaSDS GUI values [#18444](https://github.com/arendst/Tasmota/issues/18444) -- Berry fix rules for string comparisons [#18464](https://github.com/arendst/Tasmota/issues/18464) \ No newline at end of file +- Berry fix rules for string comparisons [#18464](https://github.com/arendst/Tasmota/issues/18464) +- Berry a rare condition when a GC causes a memory corruption +- Partition_Manager.tapp diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino index 6fc75ec08..1ef4fbdd4 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino @@ -124,6 +124,7 @@ typedef struct { #ifdef USE_ENERGY_MARGIN_DETECTION uint16_t power_history[ENERGY_MAX_PHASES][3]; uint8_t power_steady_counter; // Allow for power on stabilization + uint8_t margin_stable; bool min_power_flag; bool max_power_flag; bool min_voltage_flag; @@ -556,7 +557,8 @@ void EnergyMarginCheck(void) { if (jsonflg) { ResponseJsonEndEnd(); MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_MARGINS), MQTT_TELE_RETAIN); - EnergyMqttShow(); +// EnergyMqttShow(); + Energy->margin_stable = 3; // Allow 2 seconds to stabilize before reporting } #ifdef USE_ENERGY_POWER_LIMIT @@ -681,6 +683,12 @@ void EnergyEverySecond(void) { #ifdef USE_ENERGY_MARGIN_DETECTION EnergyMarginCheck(); + if (Energy->margin_stable) { + Energy->margin_stable--; + if (!Energy->margin_stable) { + EnergyMqttShow(); + } + } #endif // USE_ENERGY_MARGIN_DETECTION } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino index 2261c53f2..c7d8be494 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino @@ -176,6 +176,7 @@ typedef struct { uint8_t fifth_second; uint8_t command_code; uint8_t power_steady_counter; // Allow for power on stabilization + uint8_t margin_stable; uint8_t mplr_counter; uint8_t max_energy_state; @@ -772,7 +773,8 @@ void EnergyMarginCheck(void) { if (jsonflg) { ResponseJsonEndEnd(); MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_MARGINS), MQTT_TELE_RETAIN); - EnergyMqttShow(); +// EnergyMqttShow(); + Energy->margin_stable = 3; // Allow 2 seconds to stabilize before reporting } // Max Power @@ -893,6 +895,12 @@ void EnergyEverySecond(void) { } EnergyMarginCheck(); + if (Energy->margin_stable) { + Energy->margin_stable--; + if (!Energy->margin_stable) { + EnergyMqttShow(); + } + } } /*********************************************************************************************\