X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=official%2Flights-off-with-no-motion-and-presence.groovy;fp=official%2Flights-off-with-no-motion-and-presence.groovy;h=1f48c1cff00ceed02d8c1e9bd15c738c0b49e5c3;hb=48246ae5096a4b15f9eab7fa153612be28bc88af;hp=bf739f154c14a7347ef1911dabc150793e57835d;hpb=206fd2501002a6e6e681dbedd4e75073e3a1c239;p=smartapps.git 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 +}