Power loss for few hours everyday causing timers to go off track

I live in a country where power loss occurs everyday for a few hours multiple times a day.

I want to run a light cycle for 12 hours on and 12 hours off.
Assuming lights supposed come on at 4pm and off at 4am and power loss occurs at 3am for 2-4hours. After power is restored the timer will be out of sync or if using last state setting the light can stay off or come back on depending on the time I lost power.

For now I have reverted to using a digital plug timer with my sonoff switch permanently on so I can view it though ewelink app only when the plug timer is on the 12hours on cycle

Power on state and timer works like nothing happens?
Try set the timer via scene ‘time of the day’, not via the device setting page.