Skip MQTT response if command is prefixed with underscore (#21740)

This commit is contained in:
Theo Arends 2024-07-08 16:57:21 +02:00
parent 09b2670c45
commit 105a08dd20
3 changed files with 13 additions and 5 deletions

View File

@ -16,6 +16,8 @@ All notable changes to this project will be documented in this file.
- Berry `int64` added `low32()` and `high32()` methods, used in Matter (#21728)
- Matter support for 'Generic Switch' based on Tasmota Buttons (#21731)
- Berry cam module and img class (#21743)
- Skip MQTT response if command is prefixed with underscore (#21740)
- Skip MQTT response if commands are executed prefixed with ``Backlog2`` (no delay) or ``Backlog3`` (#21740)
### Breaking Changed

View File

@ -124,6 +124,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Support for QMP6988 temperature and pressure sensor
- Support for Sonoff WTS01 temperature sensor using SerialBridge in ``SSerialMode 3``
- Support for Sonoff POWCT Ring [#21131](https://github.com/arendst/Tasmota/issues/21131)
- Skip MQTT response if command is prefixed with underscore [#21740](https://github.com/arendst/Tasmota/issues/21740)
- Skip MQTT response if commands are executed prefixed with ``Backlog2`` (no delay) or ``Backlog3`` [#21740](https://github.com/arendst/Tasmota/issues/21740)
- Extend command ``SetOption147 1`` to disable publish of IRReceived MQTT messages [#21574](https://github.com/arendst/Tasmota/issues/21574)
- NeoPool data validation and communication statistics default enabled for ESP32 only [#21721](https://github.com/arendst/Tasmota/issues/21721)
- ESP32 support for power and energy limit checks, like ``MaxEnergy2`` per phase [#21695](https://github.com/arendst/Tasmota/issues/21695)

View File

@ -374,7 +374,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) {
}
char stemp1[TOPSZ];
GetFallbackTopic_P(stemp1, ""); // Full Fallback topic = cmnd/DVES_xxxxxxxx_fb/
GetFallbackTopic_P(stemp1, ""); // Full Fallback topic = cmnd/DVES_xxxxxxxx_fb/
TasmotaGlobal.fallback_topic_flag = (!strncmp(topicBuf, stemp1, strlen(stemp1)));
char *type = strrchr(topicBuf, '/'); // Last part of received topic is always the command (type)
@ -384,13 +384,13 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) {
if (type != nullptr) {
type++;
uint32_t i;
int nLen; // strlen(type)
int nLen; // strlen(type)
char *s = type;
for (nLen = 0; *s; s++, nLen++) {
*s=toupper(*s);
}
i = nLen;
if (i > 0) { // may be 0
if (i > 0) { // may be 0
while (isdigit(type[i-1])) {
i--;
}
@ -400,13 +400,17 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) {
user_index = true;
}
type[i] = '\0';
if ((i > 1) && ('_' == type[0])) {
type++; // Skip leading _ in command
TasmotaGlobal.no_mqtt_response = true;
}
bool binary_data = (index > 299); // Suppose binary data on topic index > 299
bool binary_data = (index > 299); // Suppose binary data on topic index > 299
if (!binary_data) {
bool keep_spaces = ((strstr_P(type, PSTR("SERIALSEND")) != nullptr) && (index > 9)); // Do not skip leading spaces on (s)serialsend10 and up
if (!keep_spaces) {
while (*dataBuf && isspace(*dataBuf)) {
dataBuf++; // Skip leading spaces in data
dataBuf++; // Skip leading spaces in data
data_len--;
}
}