From f9dd36b8c3578b8f9d5bd94f4e397419e1b2d6fc Mon Sep 17 00:00:00 2001 From: Erik Thayer Date: Tue, 11 Apr 2017 14:03:22 -0500 Subject: [PATCH] add missing function --- .../lock-manager.src/lock-manager.groovy | 26 +++++++++++++++++++ .../ethayer/lock-user.src/lock-user.groovy | 8 ++++++ 2 files changed, 34 insertions(+) diff --git a/smartapps/ethayer/lock-manager.src/lock-manager.groovy b/smartapps/ethayer/lock-manager.src/lock-manager.groovy index 0f8adf6..1b53e78 100755 --- a/smartapps/ethayer/lock-manager.src/lock-manager.groovy +++ b/smartapps/ethayer/lock-manager.src/lock-manager.groovy @@ -364,3 +364,29 @@ def debugger(message) { return log.debug(message) } } + +private anyoneHome(sensors) { + def result = false + if(sensors.findAll { it?.currentPresence == "present" }) { + result = true + } + result +} + +def executeHelloPresenceCheck(routines) { + if (userNoRunPresence && userDoRunPresence == null) { + if (!anyoneHome(userNoRunPresence)) { + location.helloHome.execute(routines) + } + } else if (userDoRunPresence && userNoRunPresence == null) { + if (anyoneHome(userDoRunPresence)) { + location.helloHome.execute(routines) + } + } else if (userDoRunPresence && userNoRunPresence) { + if (anyoneHome(userDoRunPresence) && !anyoneHome(userNoRunPresence)) { + location.helloHome.execute(routines) + } + } else { + location.helloHome.execute(routines) + } +} diff --git a/smartapps/ethayer/lock-user.src/lock-user.groovy b/smartapps/ethayer/lock-user.src/lock-user.groovy index 56c3412..115964d 100755 --- a/smartapps/ethayer/lock-user.src/lock-user.groovy +++ b/smartapps/ethayer/lock-user.src/lock-user.groovy @@ -947,6 +947,14 @@ def debugger(message) { } } +private anyoneHome(sensors) { + def result = false + if(sensors.findAll { it?.currentPresence == "present" }) { + result = true + } + result +} + def executeHelloPresenceCheck(routines) { if (userNoRunPresence && userDoRunPresence == null) { if (!anyoneHome(userNoRunPresence)) {