Automation-friendly data for Sunrise/Sunset Time?

Now that we have reached The Dark Times (after the time change), I would like to be able to easily find the sunset/sunrise time for our location.

Does anyone know a site that publishes that in XML or JSON? I was hoping the National Weather Service in the USA would include it with the forecast page (https://forecast.weather.gov/MapClick.php?lat=44.58&lon=-73.51 is the local one for me) because that data is also in XML, but I don’t see it there.

p.s. - please note this is for the Mac

https://sunrise-sunset.org/api

1 Like

+1 for sunrise-sunset.org, though some colleagues think you should (and you can) calculate this yourself instead of making an API call…

(I use the API)

Some days I love the Internet.

Thank you!

(I will be using the API! :slight_smile:)

It now occurs to me that I feel like I ought to be able to automate things on my Mac at Sunrise and Sunset using Shortcuts.

But I can’t seem to figure out how to do that. Am I missing something?

You either need to run something each day to programmatically set or update the scheduler with the jobs you wish to run. One way of doing this would be to tag the reschedule onto the end of the job that runs - e.g. your daily sunrise job runs as a one off and then schedules a new instance of itself to run at tomorrow’s sunrise. The precise approach on how to do it would be determined by your scheduler, and not all schedulers support automation.

Your other option would be to use a dedicated tool like sunwait.

If you want the Sunrise and Sunset times you can also use Siri shortcuts. The standard Weather App can provide these times. No need to use the API of a Website.

First you fetch the current weather details with “Get Current Weather” at the current location and then you select “Get Details of Weather Condition”. There you can find the variables for the Sunrise Time and Sunset Time.

1 Like

Theoretically, that would be the answer, but:

  1. I can’t see any way to have it run automatically

  2. It doesn’t work reliably right not because Shortcuts on Monterey is hot garbage.

As far as scheduling… this looks like a job for at … but I haven’t used at for years. At one point at didn’t work reliably on macOS. I wonder if that is no longer true.

sunwait looks like it might be ideal for getting the info I want. Thanks!! It compiled and ran without any tweaking necessary.