Skip to content

Commit

Permalink
add missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
ethayer committed Apr 11, 2017
1 parent ea8e63b commit f9dd36b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
26 changes: 26 additions & 0 deletions smartapps/ethayer/lock-manager.src/lock-manager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
8 changes: 8 additions & 0 deletions smartapps/ethayer/lock-user.src/lock-user.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit f9dd36b

Please sign in to comment.