From fd7d2fc0a4920ae34d30e3fcf7a9bbb697dcf9e3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:00:47 +0200 Subject: [PATCH] Add entered command to MQTT command unknown message --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/tasmota_support/support_command.ino | 24 ++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b704d3944..0be82154c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. ### Changed - Refactored I2C drivers HTU21, BH1750 and HYT +- Add entered command to MQTT command unknown message ### Fixed - Shutter missing HOLD on shutterbutton (#22108) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index af0b6d471..7cfdeba3d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -144,6 +144,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - ESP32 platform update from 2024.08.10 to 2024.08.11 [#22021](https://github.com/arendst/Tasmota/issues/22021) - ESP32 LVGL library from v9.1.0 to v9.2.0 [#22031](https://github.com/arendst/Tasmota/issues/22031) - GPIOViewer from v1.5.5 to v1.5.6 +- Add entered command to MQTT command unknown message - Energy BL09xx command ``CurrentSet`` input changed from Ampere to milliAmpere - Energy force Apparent Power equals Active Power when (Calculated) Apparent Power is less than Active Power [#20653](https://github.com/arendst/Tasmota/issues/20653) - Refactored I2C drivers HTU21, BH1750 and HYT diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 92b612223..fa16fd460 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -379,6 +379,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) { char *type = strrchr(topicBuf, '/'); // Last part of received topic is always the command (type) + bool command_unknown = false; uint32_t index = 1; bool user_index = false; if (type != nullptr) { @@ -448,32 +449,29 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) { XdrvMailbox.data = dataBuf; #ifdef USE_SCRIPT_SUB_COMMAND - // allow overwrite tasmota cmds - if (!Script_SubCmd()) { + if (!Script_SubCmd()) { // Allow override tasmota cmds +#endif // USE_SCRIPT_SUB_COMMAND if (!DecodeCommand(kTasmotaCommands, TasmotaCommand, kTasmotaSynonyms)) { if (!XdrvCall(FUNC_COMMAND)) { if (!XsnsCall(FUNC_COMMAND)) { - type = nullptr; // Unknown command + command_unknown = true; // Unknown command } } } - } -#else // USE_SCRIPT_SUB_COMMAND - if (!DecodeCommand(kTasmotaCommands, TasmotaCommand, kTasmotaSynonyms)) { - if (!XdrvCall(FUNC_COMMAND)) { - if (!XsnsCall(FUNC_COMMAND)) { - type = nullptr; // Unknown command - } - } +#ifdef USE_SCRIPT_SUB_COMMAND } #endif // USE_SCRIPT_SUB_COMMAND + } else { // type = nullptr + stemp1[0] = '\0'; + type = (char*)stemp1; + command_unknown = true; // Unknown command } - if (type == nullptr) { + if (command_unknown) { TasmotaGlobal.blinks = 201; + Response_P(PSTR("{\"" D_JSON_COMMAND "\":\"%s%s" D_JSON_UNKNOWN "\"}"), type, (strlen(type))?" ":""); snprintf_P(stemp1, sizeof(stemp1), PSTR(D_JSON_COMMAND)); - Response_P(PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_UNKNOWN "\"}")); type = (char*)stemp1; }