diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 4307b4b31..0106bfc68 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -5,6 +5,7 @@ * Add blend RGB leds with White leds for better whites (#5895, #5704) * Add command SetOption41 0..8 to control number of Tuya switches (#6039) * Add command SetOption42 0..255 to set overtemperature (Celsius only) threshold resulting in power off all on energy monitoring devices. Default setting is 90 (#6036) + * Add command SetOption66 0/1 to enable or disable Tuya dimmer range 255 slider control * Add command Time to disable NTP and set UTC time as Epoch value if above 1451602800 (=20160101). Time 0 re-enables NTP (#5279) * Add AZ7798 automatic setting of clock display (#6034) * Add Epoch and UptimeSec to JSON messages (#6068) diff --git a/sonoff/settings.h b/sonoff/settings.h index 0fa7f5d48..8b593f9ec 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -78,8 +78,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t no_hold_retain : 1; // bit 12 (v6.4.1.19) - SetOption62 - Don't use retain flag on HOLD messages 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 tuya_show_dimmer : 1; // bit 15 (v6.5.0.15) - SetOption65 - Enable or Disable Dimmer slider control - uint32_t spare16 : 1; + uint32_t tuya_show_dimmer : 1; // bit 15 (v6.5.0.15) - SetOption65 - Enable or Disable Dimmer slider control + uint32_t tuya_dimmer_range_255 : 1; // bit 16 (v6.6.0.2) - SetOption66 - Enable or Disable Dimmer range 255 slider control uint32_t spare17 : 1; uint32_t spare18 : 1; uint32_t spare19 : 1; diff --git a/sonoff/xdrv_16_tuyadimmer.ino b/sonoff/xdrv_16_tuyadimmer.ino index 7f26e035c..f2328cc83 100644 --- a/sonoff/xdrv_16_tuyadimmer.ino +++ b/sonoff/xdrv_16_tuyadimmer.ino @@ -146,14 +146,20 @@ void LightSerialDuty(uint8_t duty) if (duty < 25) { duty = 25; } // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself if (Settings.flag3.tuya_show_dimmer == 0) { - - AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]); - + if(Settings.flag3.tuya_dimmer_range_255 == 0) + { + duty = round(duty * (100. / 255.)); + } + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]); TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty); } } else { tuya_ignore_dim = false; // reset flag if (Settings.flag3.tuya_show_dimmer == 0) { + if(Settings.flag3.tuya_dimmer_range_255 == 0) + { + duty = round(duty * (100. / 255.)); + } AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim skipped value=%d"), duty); // due to 0 or already set } } @@ -211,8 +217,14 @@ void TuyaPacketProcess(void) AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]); Settings.param[P_TUYA_DIMMER_ID] = tuya_buffer[6]; } - - tuya_new_dim = round(tuya_buffer[13] * (100. / 255.)); + if(Settings.flag3.tuya_dimmer_range_255 == 0) + { + tuya_new_dim = round(tuya_buffer[13]); + } + else + { + tuya_new_dim = round(tuya_buffer[13] * (100. / 255.)); + } if ((power || Settings.flag3.tuya_apply_o20) && (tuya_new_dim > 0) && (abs(tuya_new_dim - Settings.light_dimmer) > 1)) { tuya_ignore_dim = true; diff --git a/tools/decode-config.py b/tools/decode-config.py index 0fe3e274c..3dfd1b500 100755 --- a/tools/decode-config.py +++ b/tools/decode-config.py @@ -923,7 +923,13 @@ Setting_6_5_0_15['flag3'][0].update ({ 'tuya_show_dimmer': ('