ESPHome's storage: rtc option keeps a value across restarts and OTA updates but forgets it after a power cut. It now works on three Beken chips, the BK7231T, BK7231N and BK7238, which ESPHome supports through LibreTiny. Pull request #21007 by porelli was merged into the development branch on 18 October 2026 at 00:59 UTC by bdraco, and the documentation (esphome.io #7777) followed at 02:37 UTC. Both are set for ESPHome 2026.11.

RTC memory that is really flash

These chips have no RTC memory, and on them a .noinit RAM area does not survive even a soft restart. So the new backend emulates it. An rtc preference is an ordinary FlashDB entry saved under its own name prefix. When the preferences open after a power-on, brown-out, reset pin, debugger or unknown reset, as reported by lt_get_reboot_reason(), one pass deletes every entry with that prefix before any component reads its preference. After a software restart or an OTA update, the entries are still there.

The emulation has limits that the documentation states plainly:

  • unlike real RTC memory, rtc on these chips still writes to flash, so it does not reduce flash wear;
  • a value reaches flash only at the next sync, so a reset before then loses it;
  • moving an existing preference between flash and rtc changes its stored name, so its value starts over once.

Only these three families accept rtc, because their reset reasons were checked on hardware. The BK7251 and RTL8710B are still rejected, and the RTL8710B reports every boot as unknown. If a chip ever misreads its reset reason, the failure is mild: a restart taken for a power cut starts from the component's default, and a power cut taken for a restart keeps the old value, which is what happens today. Builds that do not select rtc are unchanged byte for byte, and builds that do grow by a few hundred bytes of flash.

What works now and what is still waiting

Three options accept rtc on these chips straight away: fast_connect in the wifi component (forget the saved network after a power cut), the safe_mode counter and rtc_storage in preferences. They share the same backend, but the author has only tested it with a switch.

That switch is the main use case, and it is not merged yet. Pull request #20978, from which this one was split out during review, gives switches initial_state and restore_state with a storage choice. With both in place, a relay can turn on after a power cut but keep its last state through an OTA update or a restart. The pull request names the case it suits: a load that is also switched by a wall switch or power strip upstream. #20978 was still open on 18 October.

The author ran both changes, before the split, on a BK7231T plug with a WB2S module. Restarts and OTA updates kept the outlet off when it had been switched off, and after a 15-second power cut it came back on, as configured.