Merge pull request #4279 from emontnemery/hue_small_fix

Correctly announce non RGBWW light
This commit is contained in:
Theo Arends 2018-11-05 09:11:04 +01:00 committed by GitHub
commit 4e68e9fba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 7 deletions

View File

@ -461,15 +461,19 @@ const char HUE_DESCRIPTION_XML[] PROGMEM =
"\r\n";
const char HUE_LIGHTS_STATUS_JSON[] PROGMEM =
"{\"on\":{state},"
"\"bri\":{b},"
"\"hue\":{h},"
"\"sat\":{s},"
"\"xy\":[0.5, 0.5],"
"\"ct\":{t},"
"\"alert\":\"none\","
"\"effect\":\"none\","
"\"colormode\":\"{m}\","
"\"reachable\":true}";
"\"reachable\":true";
const char HUE_LIGHTS_STATUS_JSON_DIM[] PROGMEM =
",\"bri\":{b}";
const char HUE_LIGHTS_STATUS_JSON_RGB[] PROGMEM =
",\"hue\":{h},"
"\"sat\":{s},"
"\"xy\":[0.5, 0.5]";
const char HUE_LIGHTS_STATUS_JSON_CT[] PROGMEM =
",\"ct\":{t}";
const char HUE_LIGHTS_STATUS_JSON_CM[] PROGMEM =
",\"colormode\":\"{m}\"";
const char HUE_LIGHTS_STATUS_JSON2[] PROGMEM =
",\"type\":\"Extended color light\","
"\"name\":\"{j1\","
@ -576,6 +580,19 @@ void HueLightStatus1(byte device, String *response)
ct = LightGetColorTemp();
}
*response += FPSTR(HUE_LIGHTS_STATUS_JSON);
//The light can be dimmed
if (light_subtype >= LST_SINGLE) *response += FPSTR(HUE_LIGHTS_STATUS_JSON_DIM);
//The light has adjustabe color temperature
if (light_subtype == LST_COLDWARM || light_subtype == LST_RGBWC) *response += FPSTR(HUE_LIGHTS_STATUS_JSON_CT);
//The light has RGB
if (light_subtype >= LST_RGB) *response += FPSTR(HUE_LIGHTS_STATUS_JSON_RGB);
//The light supports colormode
if (light_subtype >= LST_COLDWARM) *response += FPSTR(HUE_LIGHTS_STATUS_JSON_CM);
*response += "}";
response->replace("{state}", (power & (1 << (device-1))) ? "true" : "false");
response->replace("{h}", String((uint16_t)(65535.0f * hue)));
response->replace("{s}", String((uint8_t)(254.0f * sat)));