How to do an 'intelligent' timer switch?

lol no worries