From ca452c5e43865bfeedbb8650090a149bd36a94bd Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:14:37 +0200 Subject: [PATCH] Add Energy->phase_count_virtual --- tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino | 1 + tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino | 1 + tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino index ffe80ba22..66fb190e1 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino @@ -109,6 +109,7 @@ typedef struct { uint8_t data_valid[ENERGY_MAX_PHASES]; uint8_t phase_count; // Number of phases active + uint8_t phase_count_virtual; // Number of virtual relays bool voltage_common; // Use common voltage bool frequency_common; // Use common frequency bool use_overtemp; // Use global temperature as overtemp trigger on internal energy monitor hardware diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino index 71a19d25e..e55da6c26 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino @@ -173,6 +173,7 @@ typedef struct { uint8_t data_valid[ENERGY_MAX_PHASES]; uint8_t phase_count; // Number of phases active + uint8_t phase_count_virtual; // Number of virtual relays uint8_t fifth_second; uint8_t command_code; uint8_t power_steady_counter; // Allow for power on stabilization diff --git a/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino b/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino index 67916a717..3f51b1ce6 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino @@ -148,8 +148,9 @@ bool NrgDummyCommand(void) { } void NrgDummyDrvInit(void) { - if (TasmotaGlobal.gpio_optiona.dummy_energy && TasmotaGlobal.devices_present) { - Energy->phase_count = (TasmotaGlobal.devices_present < ENERGY_MAX_PHASES) ? TasmotaGlobal.devices_present : ENERGY_MAX_PHASES; + uint32_t phase_count = (Energy->phase_count_virtual > 0) ? Energy->phase_count_virtual : TasmotaGlobal.devices_present; + if (TasmotaGlobal.gpio_optiona.dummy_energy && phase_count) { + Energy->phase_count = (phase_count < ENERGY_MAX_PHASES) ? phase_count : ENERGY_MAX_PHASES; if (HLW_PREF_PULSE == EnergyGetCalibration(ENERGY_POWER_CALIBRATION)) { for (uint32_t i = 0; i < Energy->phase_count; i++) {