From 0f08b4cbcabae90bdef4e5dea8ce93a1d439a14f Mon Sep 17 00:00:00 2001 From: Tedrick DUFOUR Date: Mon, 29 Nov 2021 19:27:09 +0100 Subject: [PATCH 1/2] add tuya_allow_dimmer_0 (SetOption131) --- tasmota/my_user_config.h | 1 + tasmota/settings.h | 2 +- tasmota/settings.ino | 1 + tasmota/xdrv_16_tuyamcu.ino | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index bf887ff19..d9eb64830 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -337,6 +337,7 @@ #define RF_DATA_RADIX false // [SetOption28] RF receive data format (false = hexadecimal, true = decimal) #define IR_DATA_RADIX false // [SetOption29] IR receive data format (false = hexadecimal, true = decimal) #define TUYA_SETOPTION_20 false // [SetOption54] Apply SetOption20 settings to Tuya device +#define TUYA_ALLOW_DIMMER_0 false // [SetOption131] Allow save dimmer = 0 receved by MCU #define TUYA_TEMP_SET_RES 1 // [TuyaTempSetRes] Maximum number of decimals (0 - 3) showing sensor TemperatureSet #define IR_ADD_RAW_DATA false // [SetOption58] Add IR Raw data to JSON message #define BUZZER_ENABLE false // [SetOption67] Enable buzzer when available diff --git a/tasmota/settings.h b/tasmota/settings.h index c75842aac..b168422fc 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -160,7 +160,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t disable_referer_chk : 1; // bit 14 (v9.5.0.5) - SetOption128 - (Web) Allow access without referer check uint32_t energy_phase : 1; // bit 15 (v9.5.0.9) - SetOption129 - (Energy) Show phase information uint32_t show_heap_with_timestamp : 1; // bit 16 (v9.5.0.9) - SetOption130 - (Debug) Show heap with logging timestamp - uint32_t spare17 : 1; // bit 17 + uint32_t tuya_allow_dimmer_0 : 1; // bit 17 (v10.0.0.3) - SetOption131 - (Tuya) Allow save dimmer = 0 receved by MCU uint32_t spare18 : 1; // bit 18 uint32_t spare19 : 1; // bit 19 uint32_t spare20 : 1; // bit 20 diff --git a/tasmota/settings.ino b/tasmota/settings.ino index ec09129f4..bab1870db 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -1182,6 +1182,7 @@ void SettingsDefaultSet2(void) { // Tuya flag3.tuya_apply_o20 |= TUYA_SETOPTION_20; + flag5.tuya_allow_dimmer_0 |= TUYA_ALLOW_DIMMER_0; flag3.tuya_serial_mqtt_publish |= MQTT_TUYA_RECEIVED; mbflag2.temperature_set_res |= TUYA_TEMP_SET_RES; diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 43b703c82..f44ea864f 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -842,7 +842,8 @@ void TuyaProcessStatePacket(void) { (fnId == TUYA_MCU_FUNC_CT) || (fnId == TUYA_MCU_FUNC_WHITE)) { if (Tuya.ignore_dimmer_cmd_timeout < millis()) { - if ((TasmotaGlobal.power || Settings->flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device + //if ((TasmotaGlobal.power || Settings->flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device + if ((TasmotaGlobal.power || Settings->flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0 || Settings->flag5.tuya_allow_dimmer_0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device Tuya.ignore_dim = true; TasmotaGlobal.skip_light_fade = true; From 6cbe0198cc599f23def2a2afb62edcd3724fd2ed Mon Sep 17 00:00:00 2001 From: Tedrick DUFOUR Date: Mon, 29 Nov 2021 22:46:31 +0100 Subject: [PATCH 2/2] tuya_allow_dimmer_0: edit comment --- tasmota/xdrv_16_tuyamcu.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index f44ea864f..250c28b21 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -842,8 +842,7 @@ void TuyaProcessStatePacket(void) { (fnId == TUYA_MCU_FUNC_CT) || (fnId == TUYA_MCU_FUNC_WHITE)) { if (Tuya.ignore_dimmer_cmd_timeout < millis()) { - //if ((TasmotaGlobal.power || Settings->flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device - if ((TasmotaGlobal.power || Settings->flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0 || Settings->flag5.tuya_allow_dimmer_0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device + if ((TasmotaGlobal.power || Settings->flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0 || Settings->flag5.tuya_allow_dimmer_0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device / SetOption131 Allow save dimmer = 0 receved by MCU Tuya.ignore_dim = true; TasmotaGlobal.skip_light_fade = true;