This is a pre-release BETA: Testing and feedback is highly encouraged.
Description
Use Buttons As PIN Input
Assign a multi-button controller (e.g., Aeon Labs Minimote) to be a security ‘PIN code’ input pad, which triggers a switch, lock, mode, or Hello Home action.
App Name: Use Buttons As PIN Input
Category: Safety & Security
File Name: ButtonsAsPIN.app.groovy
License: See repository and/or source code header comments.
Version: v0.1.4-beta (non-production pre-release) as of latest update.
Published/Submitted to SmartThings Marketplace: no
Published to “Browse SmartApps” in IDE: yes
Releases URL: https://github.com/CosmicPuppy/SmartThings-ButtonsAsPIN/releases/latest
Master URL: https://github.com/CosmicPuppy/SmartThings-ButtonsAsPIN
SmartApp Code Snippet (Copy code from here to paste into IDE…):
… See much later post in this Topic Thread: Code has been updated to fix bugs
. Use Buttons As PIN Input ("Security Keypad") e.g., Aeon Aeotec Minimote, ZWN-SC7 Enerwave 7 Button; trigger to Routines, lock/unlock, arm/disarm, mode, lights
Notes / Discussion
-
I have only tested with the 4-button Aeon Minimote. If you have other types of multi-button devices, I would love if you could test with these and we can work together on required code modifications.
-
PIN Combinations are thus currently restricted to selections of digit values from 1 to 4 (the app does not currently incorporate the option of “held” buttons as digit values 5 to 8, though this would be a minor enhancement). Configuration consists of selecting the number of digits in the “PIN” (min 3, max 9), and then setting the PIN via selection of each digit into each sequence slot, via the pulldown (enum) user interface.
-
After PIN definition, user configures light/switch/lock toggles, mode set, and/or Hello Home Action that will be called upon correct PIN entry detected.
-
The “toggle” concept is based on the Smart Button Controller SmartApp by SmartThings and has some behavioral ambiguity that is noted in comments in the code. I recommend that a well-written Hello Home action is specified instead of individual devices. The Hello Home action could use mode or state to decide if the PIN entry is deactivating an alarm, unlocking a door, etc., and/or the opposite. Perhaps I will change the configuration pages such that Hello Home Action is the first and most prominent choice.
-
Detection of correct PIN is based on last “n” button presses detected, where “n” is the PIN length set by the user. There is no concept of “start / end / clear” or “activate / deactivate”. I considered various possibilities, but the essence of this SmartApp is simplicity even if that reduces the level of security of the code and/or the overall functionality.
-
In order for button input to be reliably captured by the App, buttons should not be pressed faster than are acknowledged by the device. The Aeon Minimote flashes the upper right red LED a few moments after a button is pressed – it is then ok to press the next button in the PIN sequence input attempt. In reality, not waiting for acknowledgement will work in a lot of cases – there is some buffering that takes place. Uncaptured (lost) button presses are likely to occur for sequences that repeat digits (e.g., {1,1,2} requires waiting for acknowledgement between the first two presses but not between second and third presses). I presume the Aeon Minimote firmware must do some de-duping. See the source code for additional notes on this phenomenon – The SmartThings event storage for the device only seems to “fill up” in this case of repeat digits, though I could not get consistent results from trying to read those events. I also suspect that if the user does not wait for acknowledgement, Z-Wave and/or Zigbee does not guarantee the order that button presses will reach the hub, since the messages pass through the mesh, etc… (Perhaps someone here is familiar with the protocol in detail and can confirm under what circumstances input sequence is or is not preserved…?).
-
Does the term “PIN” in the name of this SmartApp reflect its functionality? Should the name and/or description, etc., use other wording such as “security keypad” or … other suggestions / ideas?
-
What about the choice of icon? (Current icon: See the silver 8-button open padlock on blue background, above).
Security Level (Complexity) of the PIN:
Based on 4 buttons and a PIN length of 3, sequence order is important, and repeated numbers are permitted: There are 64 possible PIN permutations (e.g., {1,1,1}, {1,1,2} … {1,2,3} … {1,2,4} … {4,4,4}).
The formula for the permutation count is: N^L (N=number of buttons, L=PIN length): 4^3 = 64.
A PIN length of 4 digits might be customary: 4^4 = 256 permutations.
The App permits up to a length of 9 digits in the sequence: 4^9 = 262144 permutations.
Note: Since this App only looks at the last “L” button presses in a rolling buffer, an efficient “shortcut” input sequence can be used to input all possible permutations by taking advantage of the “overlap”. These are called De Bruijn Sequences.
NB: The Aeotec / Aeon Labs Minimote is discussed in various Community Forum topics
Click to Aeotec official product page.
Some of these units are available quite cheaply (~$25-$30/each, or 3 for $70) on eBay and/or Amazon, perhaps because they are overstock of the older model (but have user upgradable firmware via USB). http://smile.amazon.com/Aeon-Labs-DSA03202-v1-Minimote/dp/B00KU7ERAW/ref=sr_1_1?ie=UTF8&qid=1419249253&sr=8-1&keywords=minimote
Thank-you!
…CosmicPuppy (Terry) - @tgauchat