Update Switches.groovy
[smartapps.git] / official / sunrise-sunset.groovy
index 417cce6367c526ac15535d2726cb13b48be50150..c00bc1135d067a27d2ced5dde2f804e9ef50d71c 100755 (executable)
@@ -46,7 +46,7 @@ preferences {
                input "sunsetOffsetDir", "enum", title: "Before or After", required: false, options: ["Before","After"]
        }
        section ("Zip code (optional, defaults to location coordinates)...") {
-               input "zipCode", "text", required: false
+               input "zipCode1", "text", required: false
        }
        section( "Notifications" ) {
         input("recipients", "contact", title: "Send notifications to") {
@@ -68,25 +68,28 @@ def updated() {
 }
 
 def initialize() {
-       subscribe(location, "position", locationPositionChange)
        subscribe(location, "sunriseTime", sunriseSunsetTimeHandler)
        subscribe(location, "sunsetTime", sunriseSunsetTimeHandler)
-
-       astroCheck()
+       
+       //astroCheck()
 }
 
 def locationPositionChange(evt) {
        log.trace "locationChange()"
-       astroCheck()
+       schedule("someTime", sunriseHandler)
+       schedule("someTime", sunsetHandler)
+       //astroCheck()
 }
 
 def sunriseSunsetTimeHandler(evt) {
        log.trace "sunriseSunsetTimeHandler()"
-       astroCheck()
+       schedule("someTime", sunriseHandler)
+       schedule("someTime", sunsetHandler)
+       //astroCheck()
 }
 
 def astroCheck() {
-       def s = getSunriseAndSunset(zipCode: zipCode, sunriseOffset: sunriseOffset, sunsetOffset: sunsetOffset)
+       def s = getSunriseAndSunset(zipCode: zipCode1, sunriseOffset: sunriseOffset, sunsetOffset: sunsetOffset)
 
        def now = new Date()
        def riseTime = s.sunrise