From e1b11a6fe7dc87679e2e71ae935e823050552606 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 15 Feb 2023 16:33:29 +0100 Subject: [PATCH] Fix Tuya Exception 3 (#17941) --- tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino | 9 +++++++++ tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino index 2e4386ad5..bd316122e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v1.ino @@ -1334,12 +1334,21 @@ void TuyaSerialInput(void) ResponseAppend_P(PSTR("}}")); if (Settings->flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt +/* for (uint8_t cmdsID = 0; sizeof(TuyaExcludeCMDsFromMQTT) > cmdsID; cmdsID++){ if (TuyaExcludeCMDsFromMQTT[cmdsID] == Tuya.buffer[3]) { isCmdToSuppress = true; break; } } +*/ + for (uint8_t cmdsID = 0; cmdsID < sizeof(TuyaExcludeCMDsFromMQTT); cmdsID++) { + if (pgm_read_byte(TuyaExcludeCMDsFromMQTT +cmdsID) == Tuya.buffer[3]) { + isCmdToSuppress = true; + break; + } + } + if (!(isCmdToSuppress && Settings->flag5.tuya_exclude_from_mqtt)) { // SetOption137 - (Tuya) When Set, avoid the (MQTT-) publish of defined Tuya CMDs (see TuyaExcludeCMDsFromMQTT) if SetOption66 is active MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED)); } else { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino index 84589b42c..6c3eb15d5 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino @@ -2120,12 +2120,21 @@ void TuyaProcessCommand(unsigned char *buffer){ // SetOption66 - Enable TuyaMcuReceived messages over Mqtt if (Settings->flag3.tuya_serial_mqtt_publish) { +/* for (uint8_t cmdsID = 0; sizeof(TuyaExcludeCMDsFromMQTT) > cmdsID; cmdsID++){ if (TuyaExcludeCMDsFromMQTT[cmdsID] == cmd) { isCmdToSuppress = true; break; } } +*/ + for (uint8_t cmdsID = 0; cmdsID < sizeof(TuyaExcludeCMDsFromMQTT); cmdsID++) { + if (pgm_read_byte(TuyaExcludeCMDsFromMQTT +cmdsID) == Tuya.buffer[3]) { + isCmdToSuppress = true; + break; + } + } + // SetOption137 - (Tuya) When Set, avoid the (MQTT-) publish of defined Tuya CMDs // (see TuyaExcludeCMDsFromMQTT) if SetOption66 is active if (!(isCmdToSuppress && Settings->flag5.tuya_exclude_from_mqtt)) {