Another sun position calculator
Posted: Wednesday 31 October 2018 19:07
I've just stumbled across this Python script for calculating sun position: https://github.com/s-bear/sun-position.
It's based on an algorithm which claims to calculate "the solar zenith and azimuth angles in the period from the year −2000 to 6000, with uncertainties of ±0.0003°".
Save it asIt runs happily on a RPi under Python 2.7 (may need some changes for Python 3.x).
I've created a separate Python script to read azimuth and zenith values from sunposition.py (zenith is converted to altitude: altitude = 90 - zenith), and then writes the values to two custom sensor devices in Domoticz:

Save the following script in the same folder as above, and run it with cron at your required frequency.
It's based on an algorithm which claims to calculate "the solar zenith and azimuth angles in the period from the year −2000 to 6000, with uncertainties of ±0.0003°".



Save it as
Code: Select all
/path_to_python_scripts/sunposition.py
I've created a separate Python script to read azimuth and zenith values from sunposition.py (zenith is converted to altitude: altitude = 90 - zenith), and then writes the values to two custom sensor devices in Domoticz:

Save the following script in the same folder as above, and run it with cron at your required frequency.
- Spoiler: show