Merge pull request #7358 from s-hadinger/fix_white

Fix: White added to light status (#7142)
This commit is contained in:
Theo Arends 2019-12-28 22:42:40 +01:00 committed by GitHub
commit 5474332b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -10,6 +10,7 @@
- Add WifiPower to ``Status 5`` - Add WifiPower to ``Status 5``
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev - Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
- Add Zigbee attribute decoder for Xiaomi Aqara Cube - Add Zigbee attribute decoder for Xiaomi Aqara Cube
- Fix ``White`` added to light status (#7142)
## Released ## Released

View File

@ -936,9 +936,11 @@ public:
switch (mode) { switch (mode) {
case 1: case 1:
changeBriRGB(bri); changeBriRGB(bri);
if (_ct_rgb_linked) { _state->setColorMode(LCM_RGB); } // try to force CT
break; break;
case 2: case 2:
changeBriCT(bri); changeBriCT(bri);
if (_ct_rgb_linked) { _state->setColorMode(LCM_CT); } // try to force CT
break; break;
default: default:
changeBri(bri); changeBri(bri);
@ -1421,6 +1423,14 @@ void LightState(uint8_t append)
bri = changeUIntScale(bri, 0, 255, 0, 100); bri = changeUIntScale(bri, 0, 255, 0, 100);
ResponseAppend_P(PSTR(",\"" D_CMND_HSBCOLOR "\":\"%d,%d,%d\""), hue,sat,bri); 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 // Add status for each channel
ResponseAppend_P(PSTR(",\"" D_CMND_CHANNEL "\":[" )); ResponseAppend_P(PSTR(",\"" D_CMND_CHANNEL "\":[" ));
for (uint32_t i = 0; i < Light.subtype; i++) { for (uint32_t i = 0; i < Light.subtype; i++) {
@ -1432,9 +1442,6 @@ void LightState(uint8_t append)
} }
ResponseAppend_P(PSTR("]")); 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 (append) {
if (Light.subtype >= LST_RGB) { if (Light.subtype >= LST_RGB) {
@ -2087,18 +2094,12 @@ void CmndColor(void)
void CmndWhite(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)) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 100)) {
uint32_t whiteBri = changeUIntScale(XdrvMailbox.payload,0,100,0,255); light_controller.changeDimmer(XdrvMailbox.payload, 2);
char scolor[LIGHT_COLOR_SIZE]; LightPreparePower(2);
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;
} }
CmndSupportColor();
} }
} }
@ -2189,7 +2190,6 @@ void CmndHsbColor(void)
if (validHSB) { if (validHSB) {
light_controller.changeHSB(HSB[0], HSB[1], HSB[2]); light_controller.changeHSB(HSB[0], HSB[1], HSB[2]);
LightPreparePower(1); LightPreparePower(1);
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_COLOR));
} }
} else { } else {
LightState(0); LightState(0);
@ -2239,6 +2239,7 @@ void CmndWakeup(void)
void CmndColorTemperature(void) void CmndColorTemperature(void)
{ {
if (Light.pwm_multi_channels) { return; }
if ((LST_COLDWARM == Light.subtype) || (LST_RGBWC == Light.subtype)) { // ColorTemp if ((LST_COLDWARM == Light.subtype) || (LST_RGBWC == Light.subtype)) { // ColorTemp
uint32_t ct = light_state.getCT(); uint32_t ct = light_state.getCT();
if (1 == XdrvMailbox.data_len) { if (1 == XdrvMailbox.data_len) {