Skip to content

Partial POST /json/cfg resets settings it does not mention (linked remotes, FPS, auto-white mode, gamma) #5883

Description

@Tycorc

What happened?

After I sent a small POST /json/cfg that only changed the LED power cap, the WiZmote I had paired stopped working. GET /json/cfg showed "linked_remote": [] where it had shown my remote's MAC before, and the empty list survived a reboot.

Reading wled00/cfg.cpp (deserializeConfig), this seems to be what the code does when the posted document has no nw object: linked_remotes.clear() runs before the lookup of nw.linked_remote, and the list is only refilled when that key is present.

  JsonObject nw = doc["nw"];
#ifndef WLED_DISABLE_ESPNOW
  CJSON(enableESPNow, nw[F("espnow")]);
  linked_remotes.clear();
  JsonVariant lrem = nw[F("linked_remote")];
  if (!lrem.isNull()) {

The neighbouring lists in the same function (nw.ins, dns, hw.btn.ins, bus ins, timers) appear to be guarded by an isNull() check, so a partial POST leaves them alone. I may be missing a reason why the remote list is handled differently; if the JSON API is expected to always send the complete nw block, this is a documentation question rather than a bug, and I would be glad to know.

As far as I can tell from the history, the earlier single-remote code used getStringFromJson, which does not touch the variable when the key is absent, and the behaviour changed with the multi-remote support in #4654. I have not bisected that, it is from reading the diff.

To Reproduce Bug

  1. Pair a WiZmote via WiFi settings → Linked MACs, confirm GET /json/cfg shows the MAC under nw.linked_remote.
  2. curl -X POST -H 'Content-Type: application/json' -d '{"hw":{"led":{"maxpwr":4000}}}' http://<wled>/json/cfg
  3. GET /json/cfg → "linked_remote": [], remote no longer reacts, still empty after reboot.

Sending the same POST with "nw":{"espnow":true,"linked_remote":["<mac>"]} included keeps the remote, which is what I do now as a workaround.

Expected Behavior

I expected a /json/cfg write to leave settings it does not mention unchanged, as it does for the WiFi list and the buttons. If that expectation is right, moving the clear() inside the if (!lrem.isNull()) block, or guarding the block with if (!nw.isNull()), would be one possible fix. Happy to open a PR if a maintainer confirms the intended behaviour.

Install Method

Self-Compiled

What version of WLED?

16.0.0 (build 2605030) on the device; the same lines are present in the 16.0.1 tag and in main as of 2026-10-03, which I only checked by reading, not by flashing.

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

GET  /json/cfg  -> "nw":{"espnow":true,"linked_remote":["4cebd6203de7"], ...}
POST /json/cfg  {"hw":{"led":{"maxpwr":4000}}}  -> {"success":true}
GET  /json/cfg  -> "nw":{"espnow":true,"linked_remote":[], ...}

Anything else?

Seen from home automation that writes single settings over the JSON API. The settings web form is not affected as far as I can see, since it submits the whole list every time.

Update 2026-10-04

Same function, 4 more settings reset on a partial POST, different cause: hw.led.rgbwm, hw.led.fps, light.gc.bri and light.gc.col fall back to a constant when the key is missing (cfg.cpp L183, L189, L531, L532 on main). After a POST with only hw.led.maxpwr: fps 30 back to 42, auto-white mode back to disabled, Brightness Gamma off, a disabled colour Gamma on again, all written to cfg.json. Confirmed on ESP8266 with 16.0.1 and main. Details in the comments, fix is in #5885 as a second commit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions