Controlling Router power relay automatically

I’m working on the same topic here:

I haven’t had a chance to try these suggestions yet.