From: Seyed Amir Hossein Aqajari Date: Fri, 9 Aug 2019 19:51:36 +0000 (-0700) Subject: Update lights-off-with-no-motion-and-presence.groovy X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartapps.git;a=commitdiff_plain;h=48246ae5096a4b15f9eab7fa153612be28bc88af Update lights-off-with-no-motion-and-presence.groovy --- diff --git a/official/lights-off-with-no-motion-and-presence.groovy b/official/lights-off-with-no-motion-and-presence.groovy index bf739f1..1f48c1c 100755 --- a/official/lights-off-with-no-motion-and-presence.groovy +++ b/official/lights-off-with-no-motion-and-presence.groovy @@ -61,20 +61,20 @@ def isActivePresence() { def scheduleCheck() { log.debug "scheduled check" def motionState = motionSensor.currentState("motion") - if (motionState.value == "inactive") { - def elapsed = now() - motionState.rawDateCreated.time - def threshold = 1000 * 60 * delayMins - 1000 - if (elapsed >= threshold) { + if (motionState == "inactive") { + //def elapsed = now() - motionState.rawDateCreated.time + //def threshold = 1000 * 60 * delayMins - 1000 + if (/*elapsed >= threshold*/true) { if (!isActivePresence()) { - log.debug "Motion has stayed inactive since last check ($elapsed ms) and no presence: turning lights off" + log.debug "Motion has stayed inactive since last check and no presence: turning lights off" switches.off() } else { log.debug "Presence is active: do nothing" } } else { - log.debug "Motion has not stayed inactive long enough since last check ($elapsed ms): do nothing" + log.debug "Motion has not stayed inactive long enough since last check: do nothing" } } else { log.debug "Motion is active: do nothing" } -} \ No newline at end of file +}