From 9fb804b426476699830838eab1f1a374c5fb087e Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Tue, 20 Aug 2019 11:13:37 +0100 Subject: [PATCH] Fix: Tuya Switches are detected as dimmers. Tuya switches are detected as dimmers even after setting SetOption65 to 1. Currently SetOption65 just hides the dimmer from Web UI for Tuya switches with SetOption65 to 1 but they are advertised as dimmer to HASS. With this change we set light_type to LT_BASIC (on/off) instead of LT_SERIAL1 (dimmable) when option 65 is set. --- sonoff/support_command.ino | 3 +++ sonoff/xdrv_01_webserver.ino | 4 +--- sonoff/xdrv_16_tuyadimmer.ino | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sonoff/support_command.ino b/sonoff/support_command.ino index 29543cd4d..9853ac974 100644 --- a/sonoff/support_command.ino +++ b/sonoff/support_command.ino @@ -621,6 +621,9 @@ void CmndSetoption(void) if (18 == pindex) { // SetOption68 for multi-channel PWM, requires a reboot restart_flag = 2; } + if (15 == pindex) { // SetOption65 for tuya_disable_dimmer requires a reboot + restart_flag = 2; + } } } else { // SetOption32 .. 49 diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 695043b15..b7541910e 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -942,9 +942,7 @@ void HandleRoot(void) if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) { WSContentSend_P(HTTP_MSG_SLIDER1, LightGetColorTemp()); } - if (!Settings.flag3.tuya_disable_dimmer) { - WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer); - } + WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer); } #endif WSContentSend_P(HTTP_TABLE100); diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index 4abdcdeac..6a916bd0f 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -291,7 +291,12 @@ bool TuyaModuleSelected(void) Settings.my_gp.io[3] = GPIO_TUYA_RX; restart_flag = 2; } - light_type = LT_SERIAL1; + if (Settings.flag3.tuya_disable_dimmer == 0) { + light_type = LT_SERIAL1; + } else { + light_type = LT_BASIC; + } + return true; }