Introducing QtKnx, the smart home library that translates your wishes into KNX protocol.

Published Monday August 14th, 2017
8 Comments on Introducing QtKnx, the smart home library that translates your wishes into KNX protocol.
Posted in Automation, Embedded, Internet of Things, Network | Tags: , ,

QtKnx is the first major step to bring home automation at the finger tips of Qt users.
Multi-platform, elegant, flexible and easy to write software for smart homes will now be possible.
All it takes is the new QtKnx library, and the already existing functionalities of Qt.

KNX is the European leader for smart home and building protocol (, with its own PC based software for programming and controlling installations. The QtKnx library offers an open source and commercially deployable alternative for this technology.

As a first step, QtKnx can be used to build the KNX client implementation that discovers KNX servers, and then controls and manages the installation behind the server. Let’s have a look on how to do that.

Test case

We are testing the QtKnx functionalities on a small KNX installation, with a board and a server (see picture below). The server is connected to our intranet.



Here is how we can discover this server using the QtKnx library:

  • get a discovery agent object (QKnxNetIpServerDiscoveryAgent agent)

  • set it up (optional)

  • ask the agent to start discovering (agent.start())

  • ask the agent for the list of discovered servers and the services they provide (agent.discoveredServers()).

    QKnxNetIpServerDiscoveryAgent agent;
    //To have the server's response sent only to the provided local IP address as opposed to the multicast one.
    //The local IP address the server's response shall be sent to.
    const auto servers = agent.discoveredServers();
    for (auto server : servers) {
        const auto serverAddress = server.controlEndpointAddress();
        const auto serverPort = server.controlEndpointPort();
        const auto serverServices =;
        for (auto it = services.constBegin(); it != services.constEnd(); ++it) {
            qInfo().noquote() << QString::fromLatin1("      KNXnet/IP %1, Version: %2")

In our case, since we are working behind a firewall, only the server connected to the intranet was discovered. Here is what we get back 
using the above piece of code: 

1 server(s) found on the network.
  Server: KNX IP BAOS 777
      Individual address: 1.2.2
      Server control endpoint:
    Supported services:
      KNXnet/IP Core, Version: 1
      KNXnet/IP Device Management, Version: 2
      KNXnet/IP Tunnel, Version: 1

Connecting to a KNX installation (e.g. using Tunneling services)

Once the server’s control endpoint address and port are retrieved from the discovery agent, we can establish a connection with the server in order to access the devices behind it. A tunneling connection allows, among other things, the sending of simple packages to, say, turn a light on and off.

To open this tunneling connection:

  • get a tunnel connection object (QKnxNetIpTunnelConnection tunnel)

  • set the local IP address. It will be passed to the server so it knows where to send its responses.

  • connect to the server using the previously discovered server’s control endpoint address and port (tunnel.connectToHost(serverIpAddress, serverPort))

  • use the tunnel to turn a light on and off, sending instructions to the KNX devices behind the server (tunnel.sendTunnelFrame(frame)). The control commands are encapsulated into Cemi frames. Fully automated and explicit frame building functions will be available soon.

  • when we’re done, we disconnect from the server (tunnel.disconnectFromHost())

    const auto servers = agent.discoveredServers();
    QHostAddress serverIpAddress = servers[0].controlEndpointAddress();
    quint16 serverPort = servers[0].controlEndpointPort();
    QKnxNetIpTunnelConnection tunnel;
    // Connecting to the previously discovered server
    tunnel.connectToHost(serverIpAddress, serverPort);
    QKnxCemiFrame frame = ... ;

UI example

Of course, being a part of Qt, inserting QtKnx functionalities into your own UI is painless. Here is how our example UI and the QtCreator environment look like.


Brought to you soon: all basic functionalities needed by a KNX client implementation, to easily control and manage the installation, with no prerequisite knowledge of KNX protocol or high level packaging style necessary.

Brought to you later: functionalities to build a KNX server, and be able to program your installation with your own Qt written software.

Did this post raise your interest? In case it did, feel free to get in touch with us to gain access to a pre-release version.

Learn more about our offerings towards the Automation sector here and read our blog post.

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Automation, Embedded, Internet of Things, Network | Tags: , ,


Rouven Raudzus says:


I like the idea of KNX getting integrated into Qt. i started my own project for this at but it seems useless now.

will QtKNX be available for older Qt versions, too?

with friendly regards,
Rouven Raudzus

Maurice Kalinowski Maurice Kalinowski says:


as we are aiming to have more modern compiler features supported, Qt 5.9 is the minimum version to be able to use Qt Knx. Potentially the minimum version will raise in a future release, but that is undecided yet.


Can you tell what licence will it be available under GPL or LGPL?

Maurice Kalinowski Maurice Kalinowski says: mentions GPL and commercial.

Amir says:

This project seems to be very interesting and will be a great addition to Qt portfolio !
Will this be an alternative to Apple’s HomeKit framework?

Maurice Kalinowski Maurice Kalinowski says:

Yes and No.

HomeKit still uses various protocols to actually talk to devices and provides something more like a layer on top of this. KNX itself manages the actual communication between devices. Other alternatives are ZigBee, potentially Weave etc. So it is a matter of perspective what is an alternative to what.

M, says:

Is it possible to try this on opensource releases?

Chris says:

I also am curious where the open source release is?

Commenting closed.

Get started today with Qt Download now