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.

http://build.smartthings.com/projects/frontdoormotiondetector/


(Matt) #3

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


(Emerson) #4

Matt, here you go
http://support.smartthings.com/entries/21699294-Weather-Methods


(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.

http://www.wunderground.com/weather/api/d/docs?d=index

Let everyone know if it worked.

twack


(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', settings.zip as String)
    
def timezone = TimeZone.getTimeZone(localData.location.tz_long)