Skip to content

Commit

Permalink
fix error handling loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ethayer committed Nov 17, 2016
1 parent 72a3a20 commit e79da20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions smartapps/ethayer/lock-manager.src/lock-manager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def pollCodeReport(evt) {
log.debug 'checking children for errors'
children.each { child ->
child.pollCodeReport(evt)
if (child.isInErrorLoop()) {
if (child.isInErrorLoop(evt.deviceId)) {
log.debug 'child is in error loop'
needPoll = true
}
}
if (needPoll) {
log.debug 'asking for poll!'
runIn(25, doPoll)
runIn(20, doPoll)
}
}

Expand Down
11 changes: 5 additions & 6 deletions smartapps/ethayer/lock-user.src/lock-user.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ def pollCodeReport(evt) {
// set user to disabled state
if (state."lock${lock.id}".enabled) {
state."lock${lock.id}".enabled = false
state."lock${lock.id}".errorLoop = false
state."lock${lock.id}".disabledReason = "Controller failed to set code"
send("Controller failed to set code for ${app.label}")
}
Expand All @@ -732,13 +733,11 @@ def pollCodeReport(evt) {
}
}

def isInErrorLoop() {
def isInErrorLoop(lockId) {
def errorInLoop = false
parent.locks.each { lock ->
if (state."lock${lock.id}".errorLoop) {
// Child is in error state
errorInLoop = true
}
if (state."lock${lockId}".errorLoop) {
// Child is in error state
errorInLoop = true
}
return errorInLoop
}
Expand Down

0 comments on commit e79da20

Please sign in to comment.