diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 2d0acc894..0444fba6b 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -6,6 +6,7 @@ - Change new Fade system much smoother, Speed now up to 40 (#6942, #3714) - Fix Arduino IDE function prototyping compile error (#6982) - Change update lib IRremoteESP8266 updated to v2.7.1, -2.7k flash and -1.5k RAM for Tasmota-IR +- Fix auto--power on/off when setting channel to non-zero or zero value, when SetOption68 1 ### 7.0.0.5 20191118 diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 3e06446ec..07e5d23a1 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1444,27 +1444,24 @@ void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = #endif // If multi-channels, then we only switch off channels with a value of zero if (Light.pwm_multi_channels) { -// for (uint32_t i = 0; i < Light.subtype; i++) { -// // if channel is non-null, channel is supposed to be on, but it is off, do Power On -// if ((Light.current_color[i]) && (bitRead(Light.power, i)) && (0 == bitRead(power, i + Light.device - 1))) { -// ExecuteCommandPower(Light.device + i, POWER_ON_NO_STATE, SRC_LIGHT); -// //bitSet(Settings.power, i + Light.device - 1); -// #ifdef DEBUG_LIGHT -// AddLog_P2(LOG_LEVEL_DEBUG, "ExecuteCommandPower ON device=%d", Light.device + i); -// #endif -// } -// // if channel is zero and channel is on, set it off -// if ((0 == Light.current_color[i]) && bitRead(power, i + Light.device - 1)) { -// ExecuteCommandPower(Light.device + i, POWER_OFF_NO_STATE, SRC_LIGHT); -// //bitClear(Settings.power, i + Light.device - 1); -// #ifdef DEBUG_LIGHT -// AddLog_P2(LOG_LEVEL_DEBUG, "ExecuteCommandPower OFF device=%d", Light.device + i); -// #endif -// } -// #ifdef USE_DOMOTICZ -// DomoticzUpdatePowerState(Light.device + i); -// #endif // USE_DOMOTICZ -// } + for (uint32_t i = 0; i < Light.subtype; i++) { + if (bitRead(channels, i)) { + // if channel is non-null, channel is supposed to be on, but it is off, do Power On + if ((Light.current_color[i]) && (!bitRead(Light.power, i))) { + if (!Settings.flag.not_power_linked) { // SetOption20 - Control power in relation to Dimmer/Color/Ct changes + ExecuteCommandPower(Light.device + i, POWER_ON_NO_STATE, SRC_LIGHT); + } + } else { + // if channel is zero and channel is on, set it off + if ((0 == Light.current_color[i]) && bitRead(Light.power, i)) { + ExecuteCommandPower(Light.device + i, POWER_OFF_NO_STATE, SRC_LIGHT); + } + } + #ifdef USE_DOMOTICZ + DomoticzUpdatePowerState(Light.device + i); + #endif // USE_DOMOTICZ + } + } } else { if (light_controller.isCTRGBLinked()) { // linked, standard if (light_state.getBri() && !(Light.power)) {