How to get sunset time?

I’m trying to get the sunset time so I can make my own version of the Sunset/Sunrise SmartApp. I’d like my devices to turn on at sunset but turn off at 2am. (a specified time)

Unfortunately, Sunrise/Sunset is not one of the example SmartApps you can browse. Any ideas?

You could follow Kris’ project. It has an implementation of sunrise sunset stuff.

The getWeatherFeature is pretty cool - where are the API docs for that?

Matt, here you go

I haven’t tried, but I believe ST implemented some of the Weather Underground API. If so, some of the other data points may work. You can give it a try by going to the link below and editing your code to fit the JSON request and parsing.

Let everyone know if it worked.


The other methods seem to work. Specifically I used geolocate to get the local timezone (since locations don’t have physical locations for android users yet)

def localData = getWeatherFeature('geolookup', as String)
def timezone = TimeZone.getTimeZone(localData.location.tz_long)