Fix for {on:"t",bri:100}

pull/2737/head
Blaž Kristan 2022-08-08 13:36:13 +02:00
rodzic acb17dc575
commit 9e828eccf6
1 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -318,10 +318,12 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
bool onBefore = bri;
getVal(root["bri"], &bri);
bool on = root["on"] | (bri > 0);
if (!on != !bri) toggleOnOff();
if (root["on"].is<const char*>() && root["on"].as<const char*>()[0] == 't') toggleOnOff();
if (root["on"].isNull()) {
if ((onBefore && bri==0) || (!onBefore && bri>0)) toggleOnOff();
} else {
bool on = root["on"] | onBefore;
if (on != onBefore || (root["on"].is<const char*>() && root["on"].as<const char*>()[0] == 't')) toggleOnOff();
}
if (bri && !onBefore) { // unfreeze all segments when turning on
for (size_t s=0; s < strip.getSegmentsNum(); s++) {