What to do in case of a power failure and all the lights are on when the power goes on

Check out the candy app.
It can detect when homey restarts, you can use that to trigger a flow to set a scene.