Decimal-to-hexadecimal conversion script for the KNX bus

Guide on how the script converts a decimal value entered by the user into hexadecimal and then sends it to the KNX bus.

Introduction

This guide explains how to create a script that converts a set of decimal values into hexadecimal and then triggers a Scenario component that sends the value on the KNX bus.

Script overview

Step 1:

Create the new variable that contains the hexadecimal value that will be added to the value sent on the KNX bus.

Fixed-value variable

Step 2:

Create the new function “scorporate_dec” and inside it the variable “pin”: this variable takes the value from the Text input component.

Create the function and set the first variable

Step 3:

Create three new variables: they split the value in the Info component into three separate parts.

Create the variables containing the values coming from the Text input component

Step 4:

The values stored in the variables are converted to hexadecimal; the function adds the character 0 if the number of characters is less than 2.

Process the decimal values and convert them to hexadecimal

Step 5:

Three new variables are created: in this part of the script they take the hexadecimal value and the prefix “0x” is added to the value.

Add the 0x prefix to the three variables

Step 6:

The new variable “tot” is created, which groups all processed variables. The value is then written to the Info component with ID 13; finally, the Scenario component is executed, sending the result on the KNX bus.

Group the variables and trigger the scenario

Download the example project to test it.

Download the script here

Last updated: