Update lights-off-with-no-motion-and-presence.groovy
authorSeyed Amir Hossein Aqajari <amiraj.95@uci.edu>
Fri, 9 Aug 2019 19:51:36 +0000 (12:51 -0700)
committerGitHub Enterprise <noreply@github.uci.edu>
Fri, 9 Aug 2019 19:51:36 +0000 (12:51 -0700)
official/lights-off-with-no-motion-and-presence.groovy

index bf739f1..1f48c1c 100755 (executable)
@@ -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
+}