I’ve read through Rich’s design pattern on the time-of-day and astro mess at least 10 times now. It’s extremely convoluted and confusing to me. Am I the only one?
Anyway I had been using my system and having a “dummy switch” turn on at sunrise and off at sunset. This let me run rules and check for whether the sun was out. Sure, worked great.
But what about restarts?
I came up with a better plan. All of my “where’s the sun” questions are now handled by the astro binding’s sun elevation channel. All I have to do is check where the sun is, for example:
if (SunElevation.state > 1) //the sun is "out" - it's daytime if (SunElevation.state > 20) //the sun is brighter
I don’t know why I fought that design pattern so long. This is all I actually need and it works great for where I live (Texas - it’s flat and we never have “midnight sun”).