diff --git a/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino b/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino index 13fac440f..94f6ff14d 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_05_pzem_ac.ino @@ -158,7 +158,7 @@ void PzemAcShow(bool json) { ResponseAppend_P(PSTR(",\"Address\":%s"), EnergyFmt(address, 0)); #ifdef USE_WEBSERVER } else { - WSContentSend_PD(HTTP_SNS_ADDRESS, WebEnergyFmt(address, 0, 2)); + WSContentSend_PD(HTTP_SNS_ADDRESS, WebEnergyFmt(address, 0)); #endif // USE_WEBSERVER } } diff --git a/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino b/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino index eed7715eb..7fe4d3b95 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_06_pzem_dc.ino @@ -43,6 +43,7 @@ struct PZEMDC_Data { uint8_t send_retry; uint8_t channel; uint8_t address; + uint8_t addr[ENERGY_MAX_PHASES]; uint8_t range; uint8_t address_step; } *PzemDc = nullptr; // Will be dynamically allocated in PzemDcDrvInit() if GPIO in use @@ -72,6 +73,7 @@ void PzemDcEverySecond(void) } else { Energy->data_valid[PzemDc->channel] = 0; if (8 == registers) { + PzemDc->addr[PzemDc->channel] = PZEM_DC_DEVICE_ADDRESS + PzemDc->channel; // 0 1 2 3 4 5 6 7 = ModBus register // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 = Buffer index @@ -178,6 +180,20 @@ bool PzemDcCommand(void) return serviced; } +void PzemDcShow(bool json) { + float address[ENERGY_MAX_PHASES]; + for (uint32_t i = 0; i < ENERGY_MAX_PHASES; i++) { + address[i] = PzemDc->addr[i]; + } + if (json) { + ResponseAppend_P(PSTR(",\"Address\":%s"), EnergyFmt(address, 0)); +#ifdef USE_WEBSERVER + } else { + WSContentSend_PD(HTTP_SNS_ADDRESS, WebEnergyFmt(address, 0)); +#endif // USE_WEBSERVER + } +} + /*********************************************************************************************\ * Interface \*********************************************************************************************/ @@ -190,6 +206,14 @@ bool Xnrg06(uint32_t function) case FUNC_ENERGY_EVERY_SECOND: if (TasmotaGlobal.uptime > 4) { PzemDcEverySecond(); } // Fix start up issue #5875 break; + case FUNC_JSON_APPEND: + PzemDcShow(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_COL_SENSOR: + PzemDcShow(0); + break; +#endif // USE_WEBSERVER case FUNC_COMMAND: result = PzemDcCommand(); break;