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 bf739f154c14a7347ef1911dabc150793e57835d..1f48c1cff00ceed02d8c1e9bd15c738c0b49e5c3 100755 (executable)
@@ -61,20 +61,20 @@ def isActivePresence() {
 def scheduleCheck() {
        log.debug "scheduled check"
        def motionState = motionSensor.currentState("motion")
 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()) {
                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 {
                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"
     }
         }
     } else {
        log.debug "Motion is active: do nothing"
     }
-}
\ No newline at end of file
+}