mirror of https://github.com/arendst/Tasmota.git
Update xdrv_20_hue.ino
This commit is contained in:
parent
6eb3c74689
commit
768c264d04
|
@ -276,6 +276,12 @@ void HueLightStatus1(uint8_t device, String *response)
|
||||||
if (bri > 254) bri = 254; // Philips Hue bri is between 1 and 254
|
if (bri > 254) bri = 254; // Philips Hue bri is between 1 and 254
|
||||||
if (bri < 1) bri = 1;
|
if (bri < 1) bri = 1;
|
||||||
|
|
||||||
|
#ifdef USE_SHUTTER
|
||||||
|
if (ShutterState(device)) {
|
||||||
|
bri = (float)(Settings.shutter_invert[device-1] ? 100 - Settings.shutter_position[device-1] : Settings.shutter_position[device-1]) / 100;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (light_type) {
|
if (light_type) {
|
||||||
light_state.getHSB(&hue, &sat, nullptr);
|
light_state.getHSB(&hue, &sat, nullptr);
|
||||||
|
|
||||||
|
@ -452,7 +458,6 @@ void HueGlobalConfig(String *path)
|
||||||
response += ",\"";
|
response += ",\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response += F("},\"groups\":{},\"schedules\":{},\"config\":");
|
response += F("},\"groups\":{},\"schedules\":{},\"config\":");
|
||||||
HueConfigResponse(&response);
|
HueConfigResponse(&response);
|
||||||
response += "}";
|
response += "}";
|
||||||
|
@ -502,7 +507,6 @@ void HueLights(String *path)
|
||||||
Script_Check_Hue(&response);
|
Script_Check_Hue(&response);
|
||||||
#endif
|
#endif
|
||||||
response += "}";
|
response += "}";
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (path->endsWith("/state")) { // Got ID/state
|
else if (path->endsWith("/state")) { // Got ID/state
|
||||||
path->remove(0,8); // Remove /lights/
|
path->remove(0,8); // Remove /lights/
|
||||||
|
@ -531,6 +535,16 @@ void HueLights(String *path)
|
||||||
response.replace("{id", String(EncodeLightId(device)));
|
response.replace("{id", String(EncodeLightId(device)));
|
||||||
response.replace("{cm", "on");
|
response.replace("{cm", "on");
|
||||||
|
|
||||||
|
#ifdef USE_SHUTTER
|
||||||
|
if (ShutterState(device)) {
|
||||||
|
if (!change) {
|
||||||
|
on = hue_json["on"];
|
||||||
|
bri = on ? 1.0f : 0.0f; // when bri is not part of this request then calculate it
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
response.replace("{re", on ? "true" : "false");
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
on = hue_json["on"];
|
on = hue_json["on"];
|
||||||
switch(on)
|
switch(on)
|
||||||
{
|
{
|
||||||
|
@ -544,6 +558,9 @@ void HueLights(String *path)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
resp = true;
|
resp = true;
|
||||||
|
#ifdef USE_SHUTTER
|
||||||
|
}
|
||||||
|
#endif // USE_SHUTTER
|
||||||
}
|
}
|
||||||
|
|
||||||
if (light_type && (local_light_subtype >= LST_SINGLE)) {
|
if (light_type && (local_light_subtype >= LST_SINGLE)) {
|
||||||
|
@ -649,6 +666,12 @@ void HueLights(String *path)
|
||||||
resp = true;
|
resp = true;
|
||||||
}
|
}
|
||||||
if (change) {
|
if (change) {
|
||||||
|
#ifdef USE_SHUTTER
|
||||||
|
if (ShutterState(device)) {
|
||||||
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Settings.shutter_invert: %d"), Settings.shutter_invert[device-1]);
|
||||||
|
SetShutterPosition(device, bri * 100.0f );
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
if (light_type && (local_light_subtype > LST_NONE)) { // not relay
|
if (light_type && (local_light_subtype > LST_NONE)) { // not relay
|
||||||
if (!Settings.flag3.pwm_multi_channels) {
|
if (!Settings.flag3.pwm_multi_channels) {
|
||||||
if (g_gotct) {
|
if (g_gotct) {
|
||||||
|
@ -696,7 +719,6 @@ void HueLights(String *path)
|
||||||
response += F("{\"state\":");
|
response += F("{\"state\":");
|
||||||
HueLightStatus1(device, &response);
|
HueLightStatus1(device, &response);
|
||||||
HueLightStatus2(device, &response);
|
HueLightStatus2(device, &response);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
response = "{}";
|
response = "{}";
|
||||||
|
|
Loading…
Reference in New Issue