How I have automated my lights

Here is a similar but more modern and robust version…