How to get sunset time?

(Scott Newman) #1

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?

(Todd Wackford) #2

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

(Matt) #3

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

(Emerson) #4

Matt, here you go

(Todd Wackford) #5

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.


(Brian Steere) #6

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)