An application for automatically turning on a smart bulb at sunset.
To calculate the sunset at a given location on a given calender we can use NOAA's General Solar Position Calculations.
The first step is to calculate the the fractional year (γ) in radians. This is done using the formula:
Using the
Finlay we can calculate the hour angle (ha) when the solar zenith is 90.833° and then use all calculations to estimate the sunset time in minutes:
Note: To calculate the sunset hour angle we use the negative hour angle.