Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,


as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.


As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!



Smart Home Forum by FIBARO Team

  • 0

KeyCode a LUA program for a Digital Key with Fibaro UBS



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.


  • 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:

Please login or register to see this link.

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...