From aa148f67a3193898cc6d5b2aaeb33f95754d9048 Mon Sep 17 00:00:00 2001 From: Joel Stein Date: Tue, 6 Nov 2018 05:29:30 +0100 Subject: [PATCH 1/4] tuya: fix SetOption20 for Oittm/Moes --- sonoff/xdrv_16_tuyadimmer.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index bf8213da2..a1356784d 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -207,7 +207,7 @@ void TuyaPacketProcess() } tuya_new_dim = round(tuya_buffer[13] * (100. / 255.)); - if((power) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 2)) { + if((power || bitRead(Settings.flag.data, 20)) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim ); From 134a10d2c409eb645400fc8d4776c6a7ddb07c90 Mon Sep 17 00:00:00 2001 From: Joel Stein Date: Tue, 6 Nov 2018 20:06:25 +0100 Subject: [PATCH 2/4] tuya: Add SetOption22 to select if brightness-commands from faceplate should be ignored while powered off --- sonoff/sonoff.ino | 1 - sonoff/xdrv_16_tuyadimmer.ino | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 09e029a15..829879c31 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -729,7 +729,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) case 6: // mqtt_button_retain (CMND_BUTTONRETAIN) case 7: // mqtt_switch_retain (CMND_SWITCHRETAIN) case 9: // mqtt_sensor_retain (CMND_SENSORRETAIN) - case 22: // mqtt_serial (SerialSend and SerialLog) case 23: // mqtt_serial_raw (SerialSend) case 25: // knx_enabled (Web config) case 27: // knx_enable_enhancement (Web config) diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index a1356784d..d31d22609 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -207,7 +207,7 @@ void TuyaPacketProcess() } tuya_new_dim = round(tuya_buffer[13] * (100. / 255.)); - if((power || bitRead(Settings.flag.data, 20)) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { + if((power || bitRead(Settings.flag.data, 22)) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim ); From 7003435b346006638c09daa8333aeee5e1a4dfc4 Mon Sep 17 00:00:00 2001 From: Joel Stein Date: Tue, 6 Nov 2018 22:58:07 +0100 Subject: [PATCH 3/4] tuya: use SetOption54 instead of SetOption22 --- sonoff/sonoff.ino | 1 + sonoff/xdrv_16_tuyadimmer.ino | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 829879c31..09e029a15 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -729,6 +729,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) case 6: // mqtt_button_retain (CMND_BUTTONRETAIN) case 7: // mqtt_switch_retain (CMND_SWITCHRETAIN) case 9: // mqtt_sensor_retain (CMND_SENSORRETAIN) + case 22: // mqtt_serial (SerialSend and SerialLog) case 23: // mqtt_serial_raw (SerialSend) case 25: // knx_enabled (Web config) case 27: // knx_enable_enhancement (Web config) diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index d31d22609..9b3630211 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -207,7 +207,7 @@ void TuyaPacketProcess() } tuya_new_dim = round(tuya_buffer[13] * (100. / 255.)); - if((power || bitRead(Settings.flag.data, 22)) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { + if((power || bitRead(Settings.flag3.data, 4)) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim ); From a2b7bdac45de9d6c0a865648c2478412bdfd9326 Mon Sep 17 00:00:00 2001 From: Joel Stein Date: Tue, 6 Nov 2018 23:27:49 +0100 Subject: [PATCH 4/4] tuya: name flag SetOption54 --- sonoff/settings.h | 2 +- sonoff/xdrv_16_tuyadimmer.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sonoff/settings.h b/sonoff/settings.h index 677a02bf3..6914379b8 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -67,7 +67,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t user_esp8285_enable : 1; // bit 1 (v6.1.1.14) uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2) uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20) - uint32_t spare04 : 1; + uint32_t tuya_apply_o20 : 1; uint32_t spare05 : 1; uint32_t spare06 : 1; uint32_t spare07 : 1; diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index 9b3630211..06926acba 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -207,7 +207,7 @@ void TuyaPacketProcess() } tuya_new_dim = round(tuya_buffer[13] * (100. / 255.)); - if((power || bitRead(Settings.flag3.data, 4)) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { + if((power || Settings.flag3.tuya_apply_o20) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim );