Determining solar elevation and azimuth to control glare?

Yesterday, I installed some automated blinds, along with an earlier this week installation of a multi sensor device. My primary motivation (beyond its cool), is to control a short period of eastern solar glare. While my current logic with lux level and time of day sort of works, I’m guessing that it won’t work as well as the sun moves back towards the winter solstice. The problem is that the lux sensor reads avg. illumination, not the beam radiation (glare), which is the issue. Keeping the sensor aligned with the glare, would require that I move the sensor each day. If I had solar azimuth and elevation data in ST, I might be able to do an automation to retrieve the NOAA values and determine if this is an issue (along with high light level). Has anyone developed something that would work in this application?

You may want to look at webcore and post your question on the webcore forum as well. There are some users who have developed pistons on solstices and equinoxes, so you can probably incorporate parts of it to use and they can help you build the rest to suite your needs.


The link above is actually my ‘baby’, but I have crafted another piston that takes this concept to another level… It accurately estimates how many degrees the sun is above the horizon at any given moment… (which can easily be incorporated into a piston that auto-closes blinds before the glare happens)

The math changes based on latitude, and changes every day due to the seasons. And of course, the height of the sun changes at every moment throughout the day, but my formula works year-round(with 99% accuracy during all of the important times of the day)

I have not shared this ‘astronomical’ formula publicly… mostly because of how much work it took to get all 57 unique math formulas to work hand-in-hand. (but it has been tested for well over a year, in many various locations around the globe)

Honestly, it is the only solar altitude estimator I have ever seen anywhere!
(my goal was to make it 100% self-contained, without using any external APIs)

I also use this method to determine when to turn on my porch lights.
(no longer basing it on sunset times, but when the sun drops below 8° from the horizon)

Feel free to send me a PM in the webCoRE forum if you are interested in this technological wonder, LOL.

Note, this is for advanced users who want a truly 'Smart" home…:

There are only a dozen households in the world that are using my code here, so due to the complexity and uniqueness of this, I will only share this beauty when “on-the-clock”…

I hope you can understand.

Edit for clarification:

My formulas were designed for those of us who live between latitude 24.0 and 65.6.

Those who live near the poles, will have days with no sunlight, and days with no darkness…
Those who live near the equator, will have days where the sun is to the north, and days where it’s to the south.

My formulas do not take this into account.

Thankfully, most of us live in the highlighted regions above, where the formulas work very well.


For a visual, I took the time to convert the results of the formula into a nice gauge.
The needle here literally shows how high is the sun above the horizon.

In this example:

  • I took screenshots every ten minutes throughout the day.
  • The current altitude (and max for the day) is on the bottom line…
  • The sun will be 40.71° above the horizon at high-noon.
    (shown by the edges of the yellow bar)
  • The eastern horizon is next to R for sunrise
  • The western horizon is next to S for sunset
  • The needle shows how many degrees is the sun over the horizon
    (with the exception at high noon - see note below)


Note: During the hour of high noon, the azimuth only changes a half a degree, so I have the needle static during that hour.

Of course, the gauge is entirely optional. Many clients only want the degrees pushed to a @global so other pistons can reference that number.

1 Like