For the majority of people, doing all that you described is a lot more work than just flipping a light switch. Let me explain with two xkcd comics, first:
https://xkcd.com/1319/
You say write your own program as if that was something everyone can do on a whim. Even experienced programmers might find relatively simple tasks can hold possible complications. So it's not as easy as just doing it. But most importantly:
https://xkcd.com/1205/
I have to get up to turn off the lights possibly once a day, most of the times I turn them on/off I'm already walking past the switch, but let's be generous and assume once a day I have to go out of my way to turn them off, and let's be extra generous and say it takes me 30 seconds to do it, so spending more than 12h trying to automate that is a waste of time because it would take me more than 5 years to gain the time I saved back. However, my Christmas lights are all plugged to a smart plug, because otherwise I would need to turn them on individually once a day and turn them off individually before going to bed, and buying a random smart plug I can control with my phone took me way less than that time, so it's worth it.
You seem to think automation is always worth it, but sometimes it's not. It depends on how much it costs (be it in money or time) vs how much you gain, and also you need to contemplate how much you lose. For example my Christmas lights are on smart plugs like I mentioned, technically someone might be able to hack them, so I wouldn't put my computer on one of them, even though it might be useful to measure power consumption, because someone might theoretically turn my computer off so the possible drawback outweigh the benefits of measure the consumption. Sure, I could design my own smart plug and use it, but that would take me a long time and I'd rather spend that time with my family.