diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9bd1601..b26a83fba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. ### Fixed - TuyaMcu v1 sequence fix (#17625) - TuyaMcu v1 timer integer overflow (#18048) +- PZEM energy monitor stabilize period on larger configs (#18103) ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 79bd9a651..99088991a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -134,3 +134,4 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - IR panasonic protocol regression from v12.0.2.4 [#18013](https://github.com/arendst/Tasmota/issues/18013) - EnergyTotal divided twice during minimal upgrade step regression from v12.3.1.3 [#18024](https://github.com/arendst/Tasmota/issues/18024) - TuyaMcu v1 timer integer overflow [#18048](https://github.com/arendst/Tasmota/issues/18048) +- PZEM energy monitor stabilize period on larger configs [#18103](https://github.com/arendst/Tasmota/issues/18103) diff --git a/tasmota/tasmota_xnrg_energy/xnrg_03_pzem004t.ino b/tasmota/tasmota_xnrg_energy/xnrg_03_pzem004t.ino index 41644df77..a965dbb6d 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_03_pzem004t.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_03_pzem004t.ino @@ -30,7 +30,7 @@ #define XNRG_03 3 -const uint32_t PZEM_STABILIZE = 30; // Number of seconds to stabilize configuration +const uint32_t PZEM_STABILIZE = 10; // Number of seconds to stabilize 1 pzem const uint32_t PZEM_RETRY = 5; // Number of 250 ms retries #include @@ -194,7 +194,7 @@ void PzemEvery250ms(void) case 4: // Total energy as 99999Wh Energy->import_active[Pzem.phase] = value / 1000.0f; // 99.999kWh if (Pzem.phase == Energy->phase_count -1) { - if (TasmotaGlobal.uptime > PZEM_STABILIZE) { + if (TasmotaGlobal.uptime > (PZEM_STABILIZE * ENERGY_MAX_PHASES)) { EnergyUpdateTotal(); } } @@ -229,7 +229,7 @@ void PzemEvery250ms(void) } else { Pzem.send_retry--; - if ((Energy->phase_count > 1) && (0 == Pzem.send_retry) && (TasmotaGlobal.uptime < PZEM_STABILIZE)) { + if ((Energy->phase_count > 1) && (0 == Pzem.send_retry) && (TasmotaGlobal.uptime < (PZEM_STABILIZE * ENERGY_MAX_PHASES))) { Energy->phase_count--; // Decrement phases if no response after retry within 30 seconds after restart if (TasmotaGlobal.discovery_counter) { TasmotaGlobal.discovery_counter += (PZEM_RETRY / 4) + 1; // Don't send Discovery yet, delay by 5 * 250ms + 1s diff --git a/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino b/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino index 242254d71..03c0f1e10 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino @@ -33,7 +33,7 @@ #define XNRG_05 5 const uint8_t PZEM_AC_DEVICE_ADDRESS = 0x01; // PZEM default address -const uint32_t PZEM_AC_STABILIZE = 30; // Number of seconds to stabilize configuration +const uint32_t PZEM_AC_STABILIZE = 10; // Number of seconds to stabilize 1 pzem #include TasmotaModbus *PzemAcModbus; @@ -79,7 +79,7 @@ void PzemAcEverySecond(void) Energy->power_factor[PzemAc.phase] = (float)((buffer[19] << 8) + buffer[20]) / 100.0f; // 1.00 Energy->import_active[PzemAc.phase] = (float)((buffer[15] << 24) + (buffer[16] << 16) + (buffer[13] << 8) + buffer[14]) / 1000.0f; // 4294967.295 kWh if (PzemAc.phase == Energy->phase_count -1) { - if (TasmotaGlobal.uptime > PZEM_AC_STABILIZE) { + if (TasmotaGlobal.uptime > (PZEM_AC_STABILIZE * ENERGY_MAX_PHASES)) { EnergyUpdateTotal(); } } @@ -103,7 +103,7 @@ void PzemAcEverySecond(void) } else { PzemAc.send_retry--; - if ((Energy->phase_count > 1) && (0 == PzemAc.send_retry) && (TasmotaGlobal.uptime < PZEM_AC_STABILIZE)) { + if ((Energy->phase_count > 1) && (0 == PzemAc.send_retry) && (TasmotaGlobal.uptime < (PZEM_AC_STABILIZE * ENERGY_MAX_PHASES))) { Energy->phase_count--; // Decrement phases if no response after retry within 30 seconds after restart if (TasmotaGlobal.discovery_counter) { TasmotaGlobal.discovery_counter += ENERGY_WATCHDOG + 1; // Don't send Discovery yet, delay by 4s + 1s diff --git a/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino b/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino index 1fddb68d0..a1d2cceb6 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino @@ -32,7 +32,7 @@ #define XNRG_06 6 const uint8_t PZEM_DC_DEVICE_ADDRESS = 0x01; // PZEM default address -const uint32_t PZEM_DC_STABILIZE = 30; // Number of seconds to stabilize configuration +const uint32_t PZEM_DC_STABILIZE = 10; // Number of seconds to stabilize 1 pzem #include TasmotaModbus *PzemDcModbus; @@ -76,7 +76,7 @@ void PzemDcEverySecond(void) Energy->active_power[PzemDc.channel] = (float)((buffer[9] << 24) + (buffer[10] << 16) + (buffer[7] << 8) + buffer[8]) / 10.0f; // 429496729.0 W Energy->import_active[PzemDc.channel] = (float)((buffer[13] << 24) + (buffer[14] << 16) + (buffer[11] << 8) + buffer[12]) / 1000.0f; // 4294967.295 kWh if (PzemDc.channel == Energy->phase_count -1) { - if (TasmotaGlobal.uptime > PZEM_DC_STABILIZE) { + if (TasmotaGlobal.uptime > (PZEM_DC_STABILIZE * ENERGY_MAX_PHASES)) { EnergyUpdateTotal(); } } @@ -100,7 +100,7 @@ void PzemDcEverySecond(void) } else { PzemDc.send_retry--; - if ((Energy->phase_count > 1) && (0 == PzemDc.send_retry) && (TasmotaGlobal.uptime < PZEM_DC_STABILIZE)) { + if ((Energy->phase_count > 1) && (0 == PzemDc.send_retry) && (TasmotaGlobal.uptime < (PZEM_DC_STABILIZE * ENERGY_MAX_PHASES))) { Energy->phase_count--; // Decrement channels if no response after retry within 30 seconds after restart if (TasmotaGlobal.discovery_counter) { TasmotaGlobal.discovery_counter += ENERGY_WATCHDOG + 1; // Don't send Discovery yet, delay by 4s + 1s diff --git a/tasmota/tasmota_xnrg_energy/xnrg_24_esp32_biopdu.ino b/tasmota/tasmota_xnrg_energy/xnrg_24_esp32_biopdu.ino index 8af5ecb85..ac681fbf3 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_24_esp32_biopdu.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_24_esp32_biopdu.ino @@ -69,7 +69,7 @@ #define BIOPDU_MAX_PHASES 6 // BioPDU support max six phases/channels const uint8_t BIOPDU_DEVICE_ADDRESS = 0x01; // PZEM default address -const uint32_t BIOPDU_STABILIZE = 30; // Number of seconds to stabilize configuration +const uint32_t BIOPDU_STABILIZE = 10; // Number of seconds to stabilize 1 device #include TasmotaModbus *BioPduModbus; @@ -273,7 +273,7 @@ bool Xnrg24(uint32_t function) } // Fix start up issue #5875 break; case FUNC_ENERGY_EVERY_SECOND: - if (TasmotaGlobal.uptime > BIOPDU_STABILIZE) + if (TasmotaGlobal.uptime > (BIOPDU_STABILIZE * BIOPDU_MAX_PHASES)) { BioPduEverySecond(); }