ESP32 and ESP8266 devices state persistent


I have recently been using Esphome for a while, I have ESP32 and ESP8266 devices (before with Tasmota until now) and I wanted to know if there is a reliable way without damaging the flash to save the state or which is the most recommended (I use homeassistant integration, I don’t know if it can be done somehow store the state there so when the connection goes out or the light goes out, recover it persistently and not damage flash)

Opinions or recommendations? Thanks in advance

default is 1min

works for esp32

It depends on application specific.

Me have f.e. Garland Switches, they toggled once or twice a day.
So, immediate state write to flash happens 1-2 times per day - any other period will wear flash more.

Can check those topics too:

1 Like

Yep, I think in 99% of cases default is ok, you don’t even need to think about it.
If you absolutely want to make sure to have the last state saved, set it 0s. It still only writes to flash when state changes.
I see that parameter more useful when you don’t need to save your state and you have states that change continuously and rapidly. In this case you can set it higher.