From 09b2670c455420ac6557b0ae64632fe593aa79db Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:53:15 +0200 Subject: [PATCH] Add command ``Backlog3`` to execute commands without response but rule processing (#21740) --- tasmota/tasmota.ino | 20 +++----------------- tasmota/tasmota_support/support_command.ino | 14 ++++++++++---- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index e466ad9b5..e93e4c7eb 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -305,8 +305,10 @@ struct TasmotaGlobal_t { bool serial_local; // Handle serial locally bool fallback_topic_flag; // Use Topic or FallbackTopic + bool no_mqtt_response; // Respond with rule processing only bool backlog_nodelay; // Execute all backlog commands with no delay bool backlog_mutex; // Command backlog pending + bool backlog_no_mqtt_response; // Set respond with rule processing only bool stop_flash_rotate; // Allow flash configuration rotation bool blinkstate; // LED state bool pwm_present; // Any PWM channel configured with SetOption15 0 @@ -711,6 +713,7 @@ void BacklogLoop(void) { free(cmd); nodelay = true; } else { + TasmotaGlobal.no_mqtt_response = TasmotaGlobal.backlog_no_mqtt_response; ExecuteCommand(cmd, SRC_BACKLOG); free(cmd); if (nodelay || TasmotaGlobal.backlog_nodelay) { @@ -719,23 +722,6 @@ void BacklogLoop(void) { break; } } while (!BACKLOG_EMPTY); -/* - // This adds 96 bytes - for (auto &cmd : backlog) { - backlog.remove(&cmd); - if (!strncasecmp_P(cmd, PSTR(D_CMND_NODELAY), strlen(D_CMND_NODELAY))) { - free(cmd); - nodelay = true; - } else { - ExecuteCommand(cmd, SRC_BACKLOG); - free(cmd); - if (nodelay || TasmotaGlobal.backlog_nodelay) { - TasmotaGlobal.backlog_timer = millis(); // Reset backlog_timer which has been set by ExecuteCommand (CommandHandler) - } - break; - } - } -*/ TasmotaGlobal.backlog_mutex = false; } if (BACKLOG_EMPTY) { diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 98a88c0d6..19aca977b 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -474,19 +474,25 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) { } if (ResponseLength()) { - MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, type); + if (TasmotaGlobal.no_mqtt_response){ // If it is activated, Tasmota will not publish MQTT messages, but it will proccess event trigger rules + XdrvRulesProcess(0); + } else { + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, type); + } } TasmotaGlobal.fallback_topic_flag = false; + TasmotaGlobal.no_mqtt_response = false; } void CmndBacklog(void) { // Backlog command1;command2;.. Execute commands in sequence with a delay in between set with SetOption34 // Backlog0 command1;command2;.. Execute commands in sequence with no delay + // Backlog2 command1;command2;.. Execute commands in sequence with no delay and no response but rule processing only + // Backlog3 command1;command2;.. Execute commands in sequence with a delay but no response but rule processing only if (XdrvMailbox.data_len) { - if (0 == XdrvMailbox.index) { - TasmotaGlobal.backlog_nodelay = true; - } + TasmotaGlobal.backlog_nodelay = (0 == (XdrvMailbox.index & 0x01)); // Backlog0, Backlog2 + TasmotaGlobal.backlog_no_mqtt_response = (2 == (XdrvMailbox.index & 0x02)); // Backlog2, Backlog3 char *blcommand = strtok(XdrvMailbox.data, ";"); while (blcommand != nullptr) {