From: Seyed Amir Hossein Aqajari Date: Wed, 7 Aug 2019 01:34:11 +0000 (-0700) Subject: Update turn-on-before-sunset.groovy X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=609d12d6435c7548fe3993dfc7a07714b03ab5dd;p=smartapps.git Update turn-on-before-sunset.groovy --- diff --git a/official/turn-on-before-sunset.groovy b/official/turn-on-before-sunset.groovy index a4ed25c..74bed7d 100644 --- a/official/turn-on-before-sunset.groovy +++ b/official/turn-on-before-sunset.groovy @@ -53,12 +53,12 @@ def sunsetTimeHandler(evt) { def scheduleTurnOn(sunsetString) { //get the Date value for the string - def sunsetTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", sunsetString) + //def sunsetTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", sunsetString) //calculate the offset - def timeBeforeSunset = new Date(sunsetTime.time - (offset * 60 * 1000)) + def timeBeforeSunset = new Date() - log.debug "Scheduling for: $timeBeforeSunset (sunset is $sunsetTime)" + log.debug "Scheduling for: $timeBeforeSunset" //schedule this to run one time runOnce(timeBeforeSunset, turnOn)