Skip to content Get in touch

Contact form

How to Connect KNX and Alexa with OpenHAB

Connecting smart home platform KNX to voice control by Amazon Alexa is a surprisingly straightforward procedure – adding a flexible open source system in between these two does the magic.

This article is a technical counterpart of an earlier blog post about Controlling Smart Homes with KNX and Amazon Alexa, in which I wrote about the solution on a higher level. I strongly recommend reading that article first, as we go to the deep end pretty quickly here.

The system consists of three separate parts: KNX controlled electricity system with a KNX IP interface, an Amazon Alexa device, and OpenHAB platform bridging the two other systems together. The article focuses on the OpenHAB part only, so the expectation is that you have a KNX powered house and you know how to purchase and configure Amazon Alexa devices.

Hardware and OpenHAB installation

To set things up, you need a Raspberry PI computer with power supply and an SD card. The first part of the set-up is straightforward.

Go to and follow the instructions. I downloaded the latest version of the Raspberry PI SD card image and wrote it to my SD card using Etcher ( Then I inserted the card into my Raspberry, plugged network cable in, powered it on, and waited for half an hour for the distribution to download the rest of the system.

I checked the IP address of the Raspberry from my router and logged in using SSH:

ssh openhabian@

The default password is openhabian. Remember to change it before continuing any further using passwd. After the change, I continued to install KNX support using OpenHabian configuration tool:

sudo openhabian-config

OpenHAB command line configuration tool main view
OpenHAB command line configuration tool.

Select Optional Components and then knxd. Wait while the installation does its magic – be warned, it took around 15 minutes in my system.

KNX daemon installation view
KNX daemon installation.

I am an Emacs user, so I installed it for easier editing with apt-get:

sudo apt-get install emacs

There is also nano editor preinstalled and you can install vim using OpenHabian configuration tool, too. In principle, any text editor goes. But I stick with Emacs.

OpenHAB Configuration

When these additional tools are installed, the next step is to use the web interface to finalise the configuration. OpenHabian provides its web service on port 8080, thus in my case

OpenHAB web user interface before configuration
OpenHAB web interface before selecting a pre-configured package.

The system shows four pre-configured packages. The recommendation is to go with Standard and that was my selection, too.

It takes a while for the system to reconfigure itself and then you see the following view:

OpenHAB web user interface after configuration
OpenHAB web interface with the standard package.

Paper UI is the new configuration tool. It is not the most straightforward to use, but things get done.

As Alexa is not able to control directly KNX, we need to create a façade for the KNX devices towards Alexa. OpenHAB is able to emulate Philips Hue lamps that can be managed using Alexa. To install Hue Emulation, I clicked the hamburger menu on the upper left corner, then Configuration and Bindings, then the blue plus-sign, and finally Misc on the new horizontal menu. As said, this is not the most straightforward admin user interface.

Hue Emulation installation view
Installing Hue Emulation.

Then I searched for Hue and got Hue Emulation with an Install button on the right side. Clicking that button installed the emulation. The next step was to install KNX binding in similar fashion, but under Bindings tab.

Finally, Hue Emulation needs to be configured to accept Alexa’s pairing request. This can be done from the hamburger menu, then Configuration and Services. There should be only Hue Emulation available. When clicking Configure, I could enable pairing and save the configuration.

Hue Emulation Configuration pop-up
Configuring Hue Emulation.

Connecting KNX to OpenHAB

The next steps are easiest done using command line and a text editor. First, KNX binding needs to be configured to be able to connect to your KNX IP gateway. By the way, if you don’t have this installed, get your electrician to install one for you. They are able to help you to select the right one. I was lucky enough to have one preinstalled in our house.

After setting the gateway, edit file /etc/openhab2/services/knx.cfg and input the right values – you should get these from the electrician who configured the system. They can be found with trial and error, too. The key values are the IP address of the KNX IP gateway and the connection mode.

The actual KNX actuators – fancy word for lamps, dimmers, shutters, etc. – are considered to be items in OpenHab lingo. I’ve added them to /etc/openhab2/items/knx.items, one per line. The items file format is explained deeper in OpenHab documentation. For example, the following line defines a simple light switch with name Kitchen Light and KNX endpoint 2/0/4 and 2/0/5 for setting and reading the state of the switch, respectively.

Switch eg_ki_l "Kitchen Light" <light> (gKitchen, gEGLight) [ "Lighting" ] { knx="2/0/4+2/0/5" }

Hue Emulation supports also dimmers that have a similar syntax as switches:

Dimmer eg_hw_l "Hallway Light" <light> (gHallway, gEGLight) [ "Lighting" ] { knx="2/2/60+<2/2/61,2/2/62,5.001:2/2/63+<5.001:2/2/64" }

The KNX string is a bit more intimidating, as a dimmer has more complex state than a simple switch, and you can control it both by setting the percentage value and moving the value up or down.

After I’ve got my KNX configurations done, I tested the controls one by one using HAB Panel. With that I could create various controls. The easiest way to test is to add a new Switch widget and then connect it to an OpenHAB item, as follows:

HAB Panel Switch configuration pop-up
Adding a new switch with HAB Panel.

After saving, I could turn the left bedroom’s lamp on and off to see that my KNX bindings were correct. I did the same exercise for each switch and dimmer – using Slider widgets – and fixed any errors I had in the KNX configuration.

Connecting Alexa

Finally, it is time to continue with Alexa. I went to to configure my device, selected Smart Home and then Devices. There is a Discover button at the bottom of the page. When I clicked that, Alexa spent 20 seconds or so scanning my network, connecting to OpenHAB mimicking to be a Hue Bridge, and reading configurations of the devices.

After that, I could say ‘Alexa, turn on kitchen light‘ – and there was light.

More about this topic

Other thoughts

More thoughts