KeyCode LUA program for a Digital Key with Fibaro UBS.
KeyCode is a LUA script to create a digital key operated by a secret code.
Requirements:
Fibaro Universal Binary Sensor (UBS).
one or two momentary switches (push buttons).
Fibaro HC2.
It permits to define:
- two secret codes (one for each UBS input)
- maximum number of failures
- captive interval during which also the valid code will be recognized as invalid
Two momentary keys can be used as keyboard to input the secret codes to open/close a door, arm/disarm alarms, turn on/off lights, etc...
How it works.
Input1 and/or Input2 of the UBS are configured to activate scenes.
By pressing one, two or three times a momentary switch (key1, key2) connected to such inputs a digit (1, 2 or 3) is entered. A sequence of such digits is a code (secret code) that can be used to control devices, arm/disarm sensors/house alarm, activate scenes.
The script permits to define secret codes of any length (any number of digits), composed only by the numbers 1, 2 or 3. Each digit of the code can be assigned to one of the keys (UBS inputs). It is possible to use only one UBS input or both the UBS inputs.
For example, the code 2, 1, 3, 3, 1 corresponds to the following sequence:
double click, one click, triple click, triple click, one click, of the key (momentary switch) to which the digit is assigned (digit to key assignment is described below). To confirm the code it needs to hold down one of the keys.
The maximum interval between each digit or code confirmation sent to the script is configurable.
Optionally it is possible to define the maximum number of consecutive code failures before to start a captive status interval during which also the right code will be refused as invalid.
A code failure happens when the code confirmation is received (switch holding down) and the entered code doesn’t match the secret code.
By one UBS and this script it is possible to manage a maximum of two secret codes, typically one code could be for activate a function (for example, arm a sensor) the other one to deactivate the function.
You can download the script (ZIP file) and the documentation (PDF) here:
http://domotica.gposta.it