- added JSON handling for irApplyToAllSelected
This commit is contained in:
Blaž Kristan 2025-01-27 21:19:22 +01:00
parent 32a75c1ff5
commit 1e1ba9afa3

View File

@ -611,9 +611,15 @@ static void decodeIRJson(uint32_t code)
handleSet(nullptr, cmdStr, false); // no stateUpdated() call here handleSet(nullptr, cmdStr, false); // no stateUpdated() call here
} }
} else { } else {
// command is JSON object (TODO: currently will not handle irApplyToAllSelected correctly) // command is JSON object
if (jsonCmdObj[F("psave")].isNull()) deserializeState(jsonCmdObj, CALL_MODE_BUTTON_PRESET); if (jsonCmdObj[F("psave")].isNull()) {
else { if (irApplyToAllSelected && jsonCmdObj["seg"].is<JsonArray>()) {
JsonObject seg = jsonCmdObj["seg"][0]; // take 1st segment from array and use it to apply to all selected segments
seg.remove("id"); // remove segment ID if it exists
jsonCmdObj["seg"] = seg; // replace array with object
}
deserializeState(jsonCmdObj, CALL_MODE_BUTTON_PRESET); // **will call stateUpdated() with correct CALL_MODE**
} else {
uint8_t psave = jsonCmdObj[F("psave")].as<int>(); uint8_t psave = jsonCmdObj[F("psave")].as<int>();
char pname[33]; char pname[33];
sprintf_P(pname, PSTR("IR Preset %d"), psave); sprintf_P(pname, PSTR("IR Preset %d"), psave);
@ -628,6 +634,7 @@ static void applyRepeatActions()
{ {
if (irEnabled == 8) { if (irEnabled == 8) {
decodeIRJson(lastValidCode); decodeIRJson(lastValidCode);
stateUpdated(CALL_MODE_BUTTON_PRESET);
return; return;
} else switch (lastRepeatableAction) { } else switch (lastRepeatableAction) {
case ACTION_BRIGHT_UP : incBrightness(); stateUpdated(CALL_MODE_BUTTON); return; case ACTION_BRIGHT_UP : incBrightness(); stateUpdated(CALL_MODE_BUTTON); return;
@ -664,7 +671,7 @@ static void decodeIR(uint32_t code)
if (irEnabled == 8) { // any remote configurable with ir.json file if (irEnabled == 8) { // any remote configurable with ir.json file
decodeIRJson(code); decodeIRJson(code);
stateUpdated(CALL_MODE_BUTTON); stateUpdated(CALL_MODE_BUTTON_PRESET);
return; return;
} }
if (code > 0xFFFFFF) return; //invalid code if (code > 0xFFFFFF) return; //invalid code