Digital pin needs to be HIGH on startup

hmm your system doesnt sounds very efficient…

you should read over this thread and about the voltage tester module the OP got. He created a system to read if there is voltage in the system, sync the relay and widgets, and also control it… without the ESP ever losing power so its super fast.