@@ -611,9 +611,15 @@ static void decodeIRJson(uint32_t code)
611611 handleSet (nullptr , cmdStr, false ); // no stateUpdated() call here
612612 }
613613 } else {
614- // command is JSON object (TODO: currently will not handle irApplyToAllSelected correctly)
615- if (jsonCmdObj[F (" psave" )].isNull ()) deserializeState (jsonCmdObj, CALL_MODE_BUTTON_PRESET);
616- else {
614+ // command is JSON object
615+ if (jsonCmdObj[F (" psave" )].isNull ()) {
616+ if (irApplyToAllSelected && jsonCmdObj[" seg" ].is <JsonArray>()) {
617+ JsonObject seg = jsonCmdObj[" seg" ][0 ]; // take 1st segment from array and use it to apply to all selected segments
618+ seg.remove (" id" ); // remove segment ID if it exists
619+ jsonCmdObj[" seg" ] = seg; // replace array with object
620+ }
621+ deserializeState (jsonCmdObj, CALL_MODE_BUTTON_PRESET); // **will call stateUpdated() with correct CALL_MODE**
622+ } else {
617623 uint8_t psave = jsonCmdObj[F (" psave" )].as <int >();
618624 char pname[33 ];
619625 sprintf_P (pname, PSTR (" IR Preset %d" ), psave);
@@ -628,6 +634,7 @@ static void applyRepeatActions()
628634{
629635 if (irEnabled == 8 ) {
630636 decodeIRJson (lastValidCode);
637+ stateUpdated (CALL_MODE_BUTTON_PRESET);
631638 return ;
632639 } else switch (lastRepeatableAction) {
633640 case ACTION_BRIGHT_UP : incBrightness (); stateUpdated (CALL_MODE_BUTTON); return ;
@@ -664,7 +671,7 @@ static void decodeIR(uint32_t code)
664671
665672 if (irEnabled == 8 ) { // any remote configurable with ir.json file
666673 decodeIRJson (code);
667- stateUpdated (CALL_MODE_BUTTON );
674+ stateUpdated (CALL_MODE_BUTTON_PRESET );
668675 return ;
669676 }
670677 if (code > 0xFFFFFF ) return ; // invalid code
0 commit comments