Skip to content

Commit

Permalink
improove UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ethayer committed Mar 10, 2017
1 parent 5c93d4c commit 754fd57
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 17 deletions.
37 changes: 37 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Lock Manager

Incomplete List of features:

* Manage user codes on locks.
* Review and manage active lock codes.
* Set lock access based on schedules.
* Receive notifications when a user used their code.
* Run Hello Home phrases based on lock/unlock events.
* Manage Hello Home phrases based on keypad inputs.

This app works using 3 child apps and 1 parent app. It is reccomended that you install all 4 apps, however if you do not use keypad devices, it is not required to install the keypad child app.

**Note:** If upgrading from any beta version, it is required to uninstall the app completly before installing. The archetecture of this app has changed in
a way that is incompatable with previous versions.

### How To Install
[User Guide](https://dl.dropboxusercontent.com/u/54190708/LockManager/v1/guide.pdf)


##

### Version 1

This app no longer requires a custom device handler, however it does require a device handler that follows best standards. Some out of date device handlers do not report codes with the correct state attributes.

One I've run into so far is garyd9's DTH for schlage locks, which I have included a copy of in this repo with the corrected event response. I am not maintaining this code, however it works and I wanted to make it easy for people to install.



### Please donate

Donations are completly optional, but if this made your life easier, please consider donating.

* Paypal- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LDYNH7HNKBWXJ&lc=US&item_name=Lock%20Code%20Manager%20Donation&item_number=40123&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="[paypal]" /></a>

* [Google Wallet-](https://www.google.com/wallet/) Send to: [email protected]
29 changes: 18 additions & 11 deletions smartapps/ethayer/keypad.src/keypad.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ preferences {
}

def installed() {
log.debug "Installed with settings: ${settings}"
debugger("Installed with settings: ${settings}")
initialize()
}

def updated() {
log.debug "Updated with settings: ${settings}"
debugger("Updated with settings: ${settings}")
initialize()
}

Expand Down Expand Up @@ -81,7 +81,7 @@ private sendSHMEvent(String shmState) {
displayed: true,
description: "System Status is ${shmState}"
]
log.debug "test ${event}"
debugger("test ${event}")
sendLocationEvent(event)
}

Expand Down Expand Up @@ -131,7 +131,7 @@ private execRoutine(armMode, userApp) {

def codeEntryHandler(evt) {
//do stuff
log.debug "Caught code entry event! ${evt.value.value}"
debugger("Caught code entry event! ${evt.value.value}")

def codeEntered = evt.value as String

Expand Down Expand Up @@ -162,7 +162,7 @@ def codeEntryHandler(evt) {

if (correctUser) {
atomicState.tries = 0
log.debug "Correct PIN entered. Change SHM state to ${armMode}"
debugger("Correct PIN entered. Change SHM state to ${armMode}")
//log.debug "Delay: ${armDelay}"
//log.debug "Data: ${data}"
//log.debug "armMode: ${armMode}"
Expand Down Expand Up @@ -209,10 +209,10 @@ def codeEntryHandler(evt) {
message = "${evt.displayName} was armed to 'Away' by ${correctUser.label}"
}

log.debug "${message}"
debugger(message)
correctUser.send(message)
} else {
log.debug 'Incorrect code!'
debugger('Incorrect code!')
atomicState.tries = atomicState.tries + 1
if (atomicState.tries >= attemptTollerance) {
keypad.sendInvalidKeycodeResponse()
Expand All @@ -221,22 +221,29 @@ def codeEntryHandler(evt) {
}
}
def sendArmCommand() {
log.debug 'Sending Arm Command.'
debugger('Sending Arm Command.')
keypad.acknowledgeArmRequest(3)
sendSHMEvent('away')
}
def sendDisarmCommand() {
log.debug 'Sending Disarm Command.'
debugger('Sending Disarm Command.')
keypad.acknowledgeArmRequest(0)
sendSHMEvent('off')
}
def sendStayCommand() {
log.debug 'Sending Stay Command.'
debugger('Sending Stay Command.')
keypad.acknowledgeArmRequest(1)
sendSHMEvent('stay')
}
def sendNightCommand() {
log.debug 'Sending Night Command.'
debugger('Sending Night Command.')
keypad.acknowledgeArmRequest(2)
sendSHMEvent('stay')
}

def debugger(message) {
def doDebugger = parent.debuggerOn()
if (doDebugger) {
log.debug(message)
}
}
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 @@ -22,9 +22,9 @@ preferences {
def mainPage() {
dynamicPage(name: 'mainPage', install: true, uninstall: true, submitOnChange: true) {
section('Create') {
app(name: 'locks', appName: 'Lock', namespace: 'ethayer', title: 'New Lock', multiple: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/user-plus.png')
app(name: 'locks', appName: 'Lock', namespace: 'ethayer', title: 'New Lock', multiple: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/new-lock.png')
app(name: 'lockUsers', appName: 'Lock User', namespace: 'ethayer', title: 'New User', multiple: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/user-plus.png')
app(name: 'keypads', appName: 'Keypad', namespace: 'ethayer', title: 'New Keypad', multiple: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/user-plus.png')
app(name: 'keypads', appName: 'Keypad', namespace: 'ethayer', title: 'New Keypad', multiple: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/keypad-plus.png')
}
section('Locks') {
def lockApps = getLockApps()
Expand Down
2 changes: 1 addition & 1 deletion smartapps/ethayer/lock-user.src/lock-user.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def mainPage() {
text = 'inactive'
}
paragraph "${text}/${usage}"
input(name: "userCode", type: "text", title: userCodeInputTitle(), required: false, defaultValue: settings."userCode", refreshAfterSelection: true)
}
section('Additional Settings') {
def actions = location.helloHome?.getPhrases()*.label
Expand All @@ -183,7 +184,6 @@ def mainPage() {
section('Setup', hideable: true, hidden: true) {
label(title: "Name for App", defaultValue: 'User: ' + userName, required: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/user.png')
input name: 'userName', title: "Name for user", required: true, image: 'https://dl.dropboxusercontent.com/u/54190708/LockManager/user.png'
input(name: "userCode", type: "text", title: userCodeInputTitle, required: false, defaultValue: settings."userCode", refreshAfterSelection: true)
input(name: "userSlot", type: "enum", options: parent.availableSlots(settings.userSlot), title: "Select slot", required: true, refreshAfterSelection: true )
}
}
Expand Down
38 changes: 35 additions & 3 deletions smartapps/ethayer/lock.src/lock.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ preferences {
page name: 'landingPage'
page name: 'setupPage'
page name: 'mainPage'
page name: 'errorPage'
page name: 'notificationPage'
page name: 'helloHomePage'
}
Expand All @@ -42,14 +43,33 @@ def initialize() {

def landingPage() {
if (lock) {
mainPage()
def unique = isUniqueLock()
if (unique){
mainPage()
} else {
errorPage()
}
} else {
setupPage()
}
}

def isUniqueLock() {
def unique = true
if (!state.installComplete) {
// only look if we're not initialized yet.
def lockApps = parent.getLockApps()
lockApps.each { lockApp ->
if (lockApp.lock.id == lock.id) {
unique = false
}
}
}
return unique
}

def setupPage() {
dynamicPage(name: "setupPage", title: "Setup Lock", nextPage: "mainPage", uninstall: true) {
dynamicPage(name: "setupPage", title: "Setup Lock", nextPage: "landingPage", uninstall: true) {
section("Choose devices for this lock") {
input(name: "lock", title: "Which Lock?", type: "capability.lock", multiple: false, required: true)
input(name: "contactSensor", title: "Which contact sensor?", type: "capability.contactSensor", multiple: false, required: false)
Expand All @@ -75,6 +95,18 @@ def mainPage() {
}
}

def errorPage() {
dynamicPage(name: "errorPage", title: "Lock Duplicate", uninstall: true, nextPage: 'landingPage') {
section("Oops!") {
paragraph 'The lock that you selected is already installed. Please choose a different Lock or choose Remove'
}
section("Choose devices for this lock") {
input(name: "lock", title: "Which Lock?", type: "capability.lock", multiple: false, required: true)
input(name: "contactSensor", title: "Which contact sensor?", type: "capability.contactSensor", multiple: false, required: false)
}
}
}

def notificationPage() {
dynamicPage(name: "notificationPage", title: "Notification Settings") {
section {
Expand Down Expand Up @@ -135,10 +167,10 @@ def setupLockData() {
// new install! Start learning!
state.codes = [:]
state.initializeComplete = false
state.installComplete = true
state.supportsKeypadData = true
state.pinLength = false
if (lock.hasAttribute('pinLength')) {
debugger('set pinLength')
state.pinLength = lock.latestValue('pinLength')
}
}
Expand Down

0 comments on commit 754fd57

Please sign in to comment.