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

@ -47,6 +47,16 @@ static void test_wraps_to_zero_after_0xFFFF() {
TEST_ASSERT_EQUAL_UINT16(0, next(true, 0xFFFF, store));
}
// NVS is newer than shades.cfg, so a load keeps the higher code.
static void test_a_load_keeps_the_higher_rolling_code() {
TEST_ASSERT_EQUAL_UINT16(500, rollingCodeAfterLoad(500, 300, false));
TEST_ASSERT_EQUAL_UINT16(700, rollingCodeAfterLoad(500, 700, false));
}
static void test_a_restore_takes_the_backups_rolling_code() {
TEST_ASSERT_EQUAL_UINT16(300, rollingCodeAfterLoad(500, 300, true));
TEST_ASSERT_EQUAL_UINT16(700, rollingCodeAfterLoad(500, 700, true));
}
int main(int argc, char **argv) {
(void)argc;
(void)argv;
@ -55,5 +65,7 @@ int main(int argc, char **argv) {
RUN_TEST(test_synced_never_reads_the_store);
RUN_TEST(test_reading_does_not_use_up_a_code);
RUN_TEST(test_wraps_to_zero_after_0xFFFF);
RUN_TEST(test_a_load_keeps_the_higher_rolling_code);
RUN_TEST(test_a_restore_takes_the_backups_rolling_code);
return UNITY_END();
}