fix: review fixes for the shades.cfg records

- A group in a backup from before version 23 has no rolling code, and a
  restore wrote 0 to NVS for it.  It keeps the code NVS has.
- A restore reads each record into one that starts as the shade, group
  or settings it replaces, so what an older version lacks stays as it
  was (the update check below version 20 among them), as before.
- restoreFile and loadFile read the rooms, shades and groups through one
  readModel(); the settings, network and radio are applied by helpers.
- The shade's tilt is forgotten where the shades are written, not in the
  conversion to a record.
- rollingCodeAfterLoad moves to RollingCode.h and its tests to
  test_rollingcode.
- The topics a deleted shade or group clears are one list each
  (MqttTopics.h), tested against what is published.
- e2e: a restore of the shades brings back every shade and group, and
  the README has the rollback check by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-29 17:25:07 +01:00
parent b525a800b0
commit 92cd54f097
13 changed files with 277 additions and 148 deletions

View file

@ -91,3 +91,22 @@ def test_a_restore_of_the_radio_alone_brings_it_back_as_it_was(request, host, to
wait_for_restart(host, token, schema, booted)
c, _, _ = synced_model(connect, schema)
assert settings(c, schema, "radio") == radio
def test_a_restore_of_the_shades_brings_them_back_as_they_were(request, host, token, connect, schema):
"""Every shade and group, their rolling codes included, from a backup taken a moment before."""
if not request.config.getoption("--reboot"):
pytest.skip("restores a backup and reboots the device: pass --reboot")
_, shades, groups = synced_model(connect, schema)
_, frames, _ = run_sync(connect(schema=schema.hash))
booted = boot_time(schema, frames)
status, _, backup = http(host, "/backup", headers=auth(token))
assert status == 200
options = json.dumps({"shades": True})
status, _, body = upload(host, "/restore", auth(token), file=backup, fields={"data": options})
assert status == 200, body
wait_for_restart(host, token, schema, booted)
_, shades_after, groups_after = synced_model(connect, schema)
assert shades_after == shades
assert groups_after == groups