Select Page

Script decimal to hexadecimal convertion and then sending the value to the KNX bus

INTRODUCTION

This guide is done to explain how to build a script that will process and convert a group of decimal characters to hexadecimal and finally trigger a Scenario component that will send the entered pin to the KNX Bus.

Script overview

Step 1:

First create the variable that stores the hexadecimal values that will be added later on to the total value that will send to the KNX bus.

Fixed value variable.
Step 2:

Create the new function “scorporate_dec“, then create the variable called “pin“, this last variable will gather the value of the Text entry.

Function creation and first variable setup.
Step 3:

Then create three new variables, this three variables will split the value displayed on the info component in three parts.

Creating the variables that will contain the values coming from the text entry component.
Step 4:

The three variables are processed to be converted to hexadecimal, then function will add a 0 on every missing character whenever the characters entered are less then 2.

Processing the decimal values and converting them to Hexadecimal.
Step 5:

Three new variables are created, in this portion of the script the variables will take the hexadecimal value and add the character “0x” to the value.

Adding the 0x character to the three variables.
Step 6:

The new variable called “tot” is created, this variable will group up all the processed variables. Then print it to the info component with ID 13, finally trigger the scenario component that will send the result to the KNX Bus.

Grouping up the variables and triggering the scenario.

Click the link below to download the script project and try it your self.

Download the script project here!

Still Need Help? Our Customer Service Is Here For You.