From 60a7a31e614ea9d9e227d7ba57dc8be5ab06a602 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 24 May 2021 17:59:47 +0200 Subject: [PATCH] Add command ``status0`` --- tasmota/support_command.ino | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 6b85364d3..ec8e96060 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -409,16 +409,39 @@ void CmndPower(void) } } +bool all_in_one = false; + void CmndStatusResponse(uint32_t index) { - char cmnd_status[10]; // STATUS11 - snprintf_P(cmnd_status, sizeof(cmnd_status), PSTR(D_CMND_STATUS "%d"), index); - MqttPublishPrefixTopicRulesProcess_P(STAT, cmnd_status); + static String all_status = (const char*) nullptr; + + if (all_in_one) { + if (99 == index) { + all_status.replace("}{", ","); + char cmnd_status[10]; // STATUS11 + snprintf_P(cmnd_status, sizeof(cmnd_status), PSTR(D_CMND_STATUS "0")); + MqttPublishPayloadPrefixTopic_P(STAT, cmnd_status, all_status.c_str()); + all_status = (const char*) nullptr; + } + if (0 == index) { + all_status = ""; + } + all_status += TasmotaGlobal.mqtt_data; + } + else if (index < 99) { + char cmnd_status[10]; // STATUS11 + char number[4] = { 0 }; + snprintf_P(cmnd_status, sizeof(cmnd_status), PSTR(D_CMND_STATUS "%s"), (index) ? itoa(index, number, 10) : ""); + MqttPublishPrefixTopicRulesProcess_P(STAT, cmnd_status); + } } void CmndStatus(void) { int32_t payload = XdrvMailbox.payload; + all_in_one = (0 == XdrvMailbox.index); + if (all_in_one) { payload = 0; } + if (payload > MAX_STATUS) { return; } // {"Command":"Error"} if (!Settings.flag.mqtt_enabled && (6 == payload)) { return; } // SetOption3 - Enable MQTT if (!TasmotaGlobal.energy_driver && (9 == payload)) { return; } @@ -458,7 +481,7 @@ void CmndStatus(void) Settings.flag.mqtt_power_retain, // CMND_POWERRETAIN Settings.flag5.mqtt_info_retain, // CMND_INFORETAIN Settings.flag5.mqtt_state_retain); // CMND_STATERETAIN - MqttPublishPrefixTopicRulesProcess_P(STAT, PSTR(D_CMND_STATUS)); + CmndStatusResponse(0); } if ((0 == payload) || (1 == payload)) { @@ -630,6 +653,8 @@ void CmndStatus(void) } #endif + CmndStatusResponse(99); + ResponseClear(); }