From e089ded193b4cbd389be29046772de504b9e5b43 Mon Sep 17 00:00:00 2001 From: Hadinger Date: Sat, 28 Dec 2019 22:32:08 +0100 Subject: [PATCH] Fix ``White`` added to light status (#7142) --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 0cb300692..df8ebd11a 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -10,6 +10,7 @@ - Add WifiPower to ``Status 5`` - Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev - Add Zigbee attribute decoder for Xiaomi Aqara Cube +- Fix ``White`` added to light status (#7142) ## Released diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 1310ff471..15e5c6053 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -936,9 +936,11 @@ public: switch (mode) { case 1: changeBriRGB(bri); + if (_ct_rgb_linked) { _state->setColorMode(LCM_RGB); } // try to force CT break; case 2: changeBriCT(bri); + if (_ct_rgb_linked) { _state->setColorMode(LCM_CT); } // try to force CT break; default: changeBri(bri); @@ -1421,6 +1423,14 @@ void LightState(uint8_t append) bri = changeUIntScale(bri, 0, 255, 0, 100); ResponseAppend_P(PSTR(",\"" D_CMND_HSBCOLOR "\":\"%d,%d,%d\""), hue,sat,bri); + // Add White level + if (LST_RGBW <= Light.subtype) { + ResponseAppend_P(PSTR(",\"" D_CMND_WHITE "\":%d"), light_state.getDimmer(2)); + } + // Add CT + if ((LST_COLDWARM == Light.subtype) || (LST_RGBWC == Light.subtype)) { + ResponseAppend_P(PSTR(",\"" D_CMND_COLORTEMPERATURE "\":%d"), light_state.getCT()); + } // Add status for each channel ResponseAppend_P(PSTR(",\"" D_CMND_CHANNEL "\":[" )); for (uint32_t i = 0; i < Light.subtype; i++) { @@ -1432,9 +1442,6 @@ void LightState(uint8_t append) } ResponseAppend_P(PSTR("]")); } - if ((LST_COLDWARM == Light.subtype) || (LST_RGBWC == Light.subtype)) { - ResponseAppend_P(PSTR(",\"" D_CMND_COLORTEMPERATURE "\":%d"), light_state.getCT()); - } if (append) { if (Light.subtype >= LST_RGB) { @@ -2087,18 +2094,12 @@ void CmndColor(void) void CmndWhite(void) { - if ((Light.subtype == LST_RGBW) && (XdrvMailbox.index == 1)) { + if (Light.pwm_multi_channels) { return; } + if ((Light.subtype >= LST_RGBW) && (XdrvMailbox.index == 1)) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 100)) { - uint32_t whiteBri = changeUIntScale(XdrvMailbox.payload,0,100,0,255); - char scolor[LIGHT_COLOR_SIZE]; - snprintf_P(scolor, sizeof(scolor), PSTR("0,0,0,%d"), whiteBri); - light_state.setBri(whiteBri); // save target Bri, will be confirmed below - XdrvMailbox.data = scolor; - XdrvMailbox.data_len = strlen(scolor); - } else { - XdrvMailbox.data_len = 0; + light_controller.changeDimmer(XdrvMailbox.payload, 2); + LightPreparePower(2); } - CmndSupportColor(); } } @@ -2189,7 +2190,6 @@ void CmndHsbColor(void) if (validHSB) { light_controller.changeHSB(HSB[0], HSB[1], HSB[2]); LightPreparePower(1); - MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_COLOR)); } } else { LightState(0); @@ -2239,6 +2239,7 @@ void CmndWakeup(void) void CmndColorTemperature(void) { + if (Light.pwm_multi_channels) { return; } if ((LST_COLDWARM == Light.subtype) || (LST_RGBWC == Light.subtype)) { // ColorTemp uint32_t ct = light_state.getCT(); if (1 == XdrvMailbox.data_len) {