Fixed responding 'xy' colot space only for devices supporting colors.

This commit is contained in:
Stephan Hadinger 2019-04-19 14:26:40 +02:00
parent 5732efa27c
commit c8f82399f3
1 changed files with 3 additions and 5 deletions

View File

@ -468,7 +468,6 @@ const char HUE_DESCRIPTION_XML[] PROGMEM =
"\r\n"; "\r\n";
const char HUE_LIGHTS_STATUS_JSON1[] PROGMEM = const char HUE_LIGHTS_STATUS_JSON1[] PROGMEM =
"{\"on\":{state}," "{\"on\":{state},"
"\"xy\":[{x}, {y}],"
"{light_status}" "{light_status}"
"\"alert\":\"none\"," "\"alert\":\"none\","
"\"effect\":\"none\"," "\"effect\":\"none\","
@ -602,7 +601,6 @@ void HueLightStatus1(uint8_t device, String *response)
float bri = 254; float bri = 254;
uint16_t ct = 0; uint16_t ct = 0;
// default xy color to white D65, https://en.wikipedia.org/wiki/Illuminant_D65 // default xy color to white D65, https://en.wikipedia.org/wiki/Illuminant_D65
float x, y;
String light_status = ""; String light_status = "";
// force ct mode for LST_COLDWARM // force ct mode for LST_COLDWARM
@ -619,6 +617,9 @@ void HueLightStatus1(uint8_t device, String *response)
light_status += "\"bri\":" + String((uint8_t)(254.0f * bri + 0.5f)) + ","; light_status += "\"bri\":" + String((uint8_t)(254.0f * bri + 0.5f)) + ",";
if (LST_RGB <= light_subtype) { // colors if (LST_RGB <= light_subtype) { // colors
float x, y;
RgbToXy(Settings.light_color[0], Settings.light_color[1], Settings.light_color[2], &x, &y);
light_status += "\"xy\":[" + String(x) + ", " + String(y) + "],";
light_status += "\"hue\":" + String((uint16_t)(65535.0f * hue + 0.5f)) + ","; light_status += "\"hue\":" + String((uint16_t)(65535.0f * hue + 0.5f)) + ",";
light_status += "\"sat\":" + String((uint8_t)(254.0f * sat + 0.5f)) + ","; light_status += "\"sat\":" + String((uint8_t)(254.0f * sat + 0.5f)) + ",";
} }
@ -626,9 +627,6 @@ void HueLightStatus1(uint8_t device, String *response)
// ct = 0 is non valid, so we put 284 as default value (medium white) // ct = 0 is non valid, so we put 284 as default value (medium white)
light_status += "\"ct\":" + String( (ct < 100) ? 284 : ct) + ","; light_status += "\"ct\":" + String( (ct < 100) ? 284 : ct) + ",";
} }
RgbToXy(Settings.light_color[0], Settings.light_color[1], Settings.light_color[2], &x, &y);
response->replace("{x}", String(x));
response->replace("{y}", String(y));
response->replace("{light_status}", light_status); response->replace("{light_status}", light_status);
response->replace("{m}", g_gotct?"ct":"hs"); response->replace("{m}", g_gotct?"ct":"hs");
} }