From 4944b308304b9eb7f84dc567a72f7b4a56a9fe50 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 25 Oct 2019 07:05:12 +0100 Subject: [PATCH] TuyaMcu : Use SetOption66 to enable / disable publishing TuyaMcuReceived over Mqtt --- sonoff/settings.h | 2 +- sonoff/settings.ino | 4 ++-- sonoff/xdrv_16_tuyamcu.ino | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sonoff/settings.h b/sonoff/settings.h index 80960260a..5f8e2f6ce 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -79,7 +79,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t no_power_feedback : 1; // bit 13 (v6.5.0.9) - SetOption63 - Don't scan relay power state at restart uint32_t use_underscore : 1; // bit 14 (v6.5.0.12) - SetOption64 - Enable "_" instead of "-" as sensor index separator uint32_t fast_power_cycle_disable : 1; // bit 15 (v6.6.0.20) - SetOption65 - Disable fast power cycle detection for device reset - uint32_t ex_tuya_dimmer_range_255 : 1; // bit 16 (v6.6.0.1) - SetOption66 - Enable or Disable Dimmer range 255 slider control + uint32_t tuya_serial_mqtt_publish : 1; // bit 16 (v6.6.0.21) - SetOption66 - Enable or Disable TuyaMcuReceived messages over Mqtt uint32_t buzzer_enable : 1; // bit 17 (v6.6.0.1) - SetOption67 - Enable buzzer when available uint32_t pwm_multi_channels : 1; // bit 18 (v6.6.0.3) - SetOption68 - Enable multi-channels PWM instead of Color PWM uint32_t ex_tuya_dimmer_min_limit : 1; // bit 19 (v6.6.0.5) - SetOption69 - Limits Tuya dimmers to minimum of 10% (25) when enabled. diff --git a/sonoff/settings.ino b/sonoff/settings.ino index f49eb9495..76dcade8c 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -1126,7 +1126,7 @@ void SettingsDelta(void) } if (Settings.version < 0x06060008) { // Move current tuya dimmer range to the new param. - if (Settings.flag3.ex_tuya_dimmer_range_255) { + if (Settings.flag3.tuya_serial_mqtt_publish) { // ex Settings.flag3.ex_tuya_dimmer_range_255 SetOption Settings.param[P_ex_DIMMER_MAX] = 100; } else { Settings.param[P_ex_DIMMER_MAX] = 255; @@ -1200,7 +1200,7 @@ void SettingsDelta(void) if (Settings.version < 0x06060014) { // Clear unused parameters for future use /* - Settings.flag3.ex_tuya_dimmer_range_255 = 0; + Settings.flag3.tuya_serial_mqtt_publish = 0; // ex Settings.flag3.ex_tuya_dimmer_range_255 Settings.flag3.ex_tuya_dimmer_min_limit = 0; Settings.param[P_ex_TUYA_RELAYS] = 0; Settings.param[P_ex_DIMMER_MAX] = 0; diff --git a/sonoff/xdrv_16_tuyamcu.ino b/sonoff/xdrv_16_tuyamcu.ino index f9f412968..f0aeccdbd 100644 --- a/sonoff/xdrv_16_tuyamcu.ino +++ b/sonoff/xdrv_16_tuyamcu.ino @@ -680,7 +680,11 @@ void TuyaSerialInput(void) ResponseAppend_P(PSTR("}}")); - MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED)); + if (Settings.flag3.tuya_serial_mqtt_publish) { + MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED)); + } else { + AddLog_P(LOG_LEVEL_DEBUG, mqtt_data); + } XdrvRulesProcess(); if (!Tuya.low_power_mode) {