From e9e0d3536871d22a9a69eb8644f5dd47adb700f4 Mon Sep 17 00:00:00 2001 From: Barbudor Date: Thu, 8 Apr 2021 22:59:44 +0200 Subject: [PATCH] command EnergyConfig --- tasmota/xdrv_03_energy.ino | 14 +++++++++++--- tasmota/xnrg_20_dummy.ino | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tasmota/xdrv_03_energy.ino b/tasmota/xdrv_03_energy.ino index c88995590..f09233069 100644 --- a/tasmota/xdrv_03_energy.ino +++ b/tasmota/xdrv_03_energy.ino @@ -43,7 +43,7 @@ enum EnergyCommands { CMND_POWERCAL, CMND_VOLTAGECAL, CMND_CURRENTCAL, CMND_FREQUENCYCAL, - CMND_POWERSET, CMND_VOLTAGESET, CMND_CURRENTSET, CMND_FREQUENCYSET, CMND_MODULEADDRESS }; + CMND_POWERSET, CMND_VOLTAGESET, CMND_CURRENTSET, CMND_FREQUENCYSET, CMND_MODULEADDRESS, CMND_NRGCONFIG }; const char kEnergyCommands[] PROGMEM = "|" // No prefix D_CMND_POWERCAL "|" D_CMND_VOLTAGECAL "|" D_CMND_CURRENTCAL "|" D_CMND_FREQUENCYCAL "|" @@ -56,7 +56,7 @@ const char kEnergyCommands[] PROGMEM = "|" // No prefix D_CMND_SAFEPOWER "|" D_CMND_SAFEPOWERHOLD "|" D_CMND_SAFEPOWERWINDOW "|" #endif // USE_ENERGY_POWER_LIMIT #endif // USE_ENERGY_MARGIN_DETECTION - D_CMND_ENERGYRESET "|" D_CMND_TARIFF ; + D_CMND_ENERGYRESET "|" D_CMND_TARIFF "|EnergyConfig"; void (* const EnergyCommand[])(void) PROGMEM = { &CmndPowerCal, &CmndVoltageCal, &CmndCurrentCal, &CmndFrequencyCal, @@ -69,7 +69,7 @@ void (* const EnergyCommand[])(void) PROGMEM = { &CmndSafePower, &CmndSafePowerHold, &CmndSafePowerWindow, #endif // USE_ENERGY_POWER_LIMIT #endif // USE_ENERGY_MARGIN_DETECTION - &CmndEnergyReset, &CmndTariff }; + &CmndEnergyReset, &CmndTariff, &CmndEnergyConfig }; const char kEnergyPhases[] PROGMEM = "|%s / %s|%s / %s / %s||[%s,%s]|[%s,%s,%s]"; @@ -761,6 +761,14 @@ void CmndModuleAddress(void) { } } +void CmndEnergyConfig(void) { + AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: xdrv_03 index:%d"), XdrvMailbox.index); + Energy.command_code = CMND_NRGCONFIG; + if (XnrgCall(FUNC_COMMAND)) { + ResponseCmndDone(); + } +} + #ifdef USE_ENERGY_MARGIN_DETECTION void CmndPowerDelta(void) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= ENERGY_MAX_PHASES)) { diff --git a/tasmota/xnrg_20_dummy.ino b/tasmota/xnrg_20_dummy.ino index 07b4a22ec..059a4ab1f 100644 --- a/tasmota/xnrg_20_dummy.ino +++ b/tasmota/xnrg_20_dummy.ino @@ -99,6 +99,9 @@ bool NrgDummyCommand(void) { } } } + else if (CMND_NRGCONFIG == Energy.command_code) { + AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Config payload:%d, data:'%s'"), XdrvMailbox.payload, XdrvMailbox.data ? XdrvMailbox.data : "null" ); + } else serviced = false; // Unknown command return serviced;