Skip to content

Commit

Permalink
Energy power delta report delayed
Browse files Browse the repository at this point in the history
Energy power delta report delayed by two seconds allowing hardware to stabilize (#17751)
  • Loading branch information
arendst committed May 11, 2023
1 parent c776885 commit 8697964
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- 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
10 changes: 9 additions & 1 deletion tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
10 changes: 9 additions & 1 deletion tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -893,6 +895,12 @@ void EnergyEverySecond(void) {
}

EnergyMarginCheck();
if (Energy->margin_stable) {
Energy->margin_stable--;
if (!Energy->margin_stable) {
EnergyMqttShow();
}
}
}

/*********************************************************************************************\
Expand Down

0 comments on commit 8697964

Please sign in to comment.