The keypad will send the data by pressing a custom button or just by inputting a combination and waiting 3 seconds.
Whenever a pin code is submitted, the structure sent to the variable will be:
DIGITS,ACTION
So, for instance, if your user has clicked the sequence 1234 and then a custom button DISARM, the output would be:
1234,disarm
If the user pressed a sequence and no action button, then the format will exclude the button, like so:
1234
Likewise, if the user only pressed a button and no sequence, this will be the format:
disarm
The best way for you to extract and use this data is through an analysis. The keypad widget offers an option to run an analysis in the User Control tab.
If you select an analysis, this is the scope that you will receive when a user sends a sequence:
[ { "bucket": "5da07e1269c7ae001b2faefe" "origin": "5da07e1269c7ae001b2faeff", "id": "5da07e1269c7ae001b2faefs", "variable": "my_variable", "created_at": "2019-10-16T00:00:00Z", "time": "2019-10-16T00:00:00Z", "value": "1234,disarm" } ]
Analyses are the best way to manipulate the data you receive from your keypad.
Since you can receive either a digit sequence, an action string, or both, the easiest way to extract the data inside of the analysis is by using the split string method.
Python scope[0].value.split(','); >> ['1234', 'disarm'] Node.js scope[0].value.split(','); >> ['1234', 'disarm']
If you select this option, the data sent by the widget will never reach the device's data storage. Keep in mind that the data sent will still be accessible inside of the analysis' scope.
This option only works if you are using this widget inside of the Run platform.
If you select this option, the data sent by the widget will have any additional object called run_user. This will be the structure of the item:
{ "bucket": "5da07e1269c7ae001b2faefe" "origin": "5da07e1269c7ae001b2faeff", "id": "5da07e1269c7ae001b2faefs", "variable": "run_user", "created_at": "2019-10-16T00:00:00Z", "time": "2019-10-16T00:00:00Z", "value": "5da07e1269c7ae001b2faeff" }
The value in this case will be the ID of the run user.