Bk7231n save state off switch

It possible save the switch state without use the preferences flash_write_interval?

I don’t want use massive writing for that.

I try a workaround to set variable time by number for “flash_write_interval” via lambda but it’s not possible.

Why don’t you want to write to flash? If it’s because fear of wearing it out, I think it’s a vastly overstated problem.

Here’s a quite from @OttoWinter himself:

So as a fundamental thing: Has anyone ever had the memory wear out? I hear a lot of people (IMO incorrectly) fearing about it, but never heard from a user actually experiencing this.

There’s also this answer on Stack Overflow,:

Anecdotal: I’ve had an ESP32 running for several years, saving to flash every hour, without any problems so far.

2 Likes

You adjust it there how you want, once a minute, ore once a day.

I think I’m on @ster1um side for this.
Even if the device won’t have problems with this, it is about optimizing the code for a good purpose…

If someone knows how to achieve this without flash_write_interval, it would be great…
I think that the best way for the device, is to write to flash only when the button is pressed, or the sensor is chaning state…

In my case, I need the restore last state to be instantly, and only two ways could do that… flash_write_interval or another solution for the writing to happen when the state or button change

You can do right after you invented free energy :rofl:

Well, that is what will happen when you activate flash writes :raised_hands: Only changed states are written to flash and the flash_write_interval will on top limit to writes accordingly. So if your little one turns the light on-off-on-off-on-off… and you set the limit to 1 minute it will only save the first state change and than after one minute again. :hourglass_flowing_sand: