Hi @marcx.han
Which board are you using? I found a workaround to this: Storing the last value to EEPROM, so when the device restarts, it reads the previously stored value. The last replies of this post might help (that’s how I did it with a NodeMCU Esp8266 )
Cheers! Marc