Close

Working with OpenHAB

A project log for KNX Raspberry Pi HAT

A HAT to easily interface a Raspberry Pi with a KNX bus.

Tijl SchepensTijl Schepens 06/30/2020 at 16:160 Comments

Everything seems to be working well with OpenHAB!!!

It took me quite some effort to get it fully working. There are many little details that need to be right or else it just won't work. Enabling logging for both KNXD and OpenHAB really helps in finding the root cause of the issue.

After installation KNXD will start automatically as a service. The options that KNXD uses to start are defined in /etc/knxd.conf My configuration is currently:

KNXD_OPTS="--eibaddr=1.1.12 -E 1.1.1:5 -n RPihat -D -T -R -S -i --layer2=tpuarts:/dev/ttyKNX1"

 Note that while debugging it is interesting to stop the service with the command "systemctl stop knxd.service" and run KNXD from the command line. This way you can enable debugging with the -t option.

Once KNXD is running, you will see it pop up as a possible interface in ETS. This makes it possible to use the Raspberry Pi + HAT as a wireless KNX programming device. You can monitor and program networks wirelessly!

Note that the option -E specifies the addresses KNXD assigns to clients that connect to it through tunneling and such. Do not assign these addresses to physical devices on your KNX bus. This will create collisions which keep you wondering day and night why it won't work...

Getting OpenHAB to communicate with KNXD is fairly easy. After installing the KNX addon, you can instantiate a KNX/IP Gateway in the Things tab under Configuration. As KNXD and OpenHAB are running on the same Raspberry Pi, the Network Address is just the local host 127.0.0.1
If you run both on a different system, the Network Address has to be the one of the system running KNXD. Of course both systems must be in the same network.

All the other settings are ok by default, except for the Local Device Address. First I thought this had to be the individual address that is assigned to KNXD. But that caused a lot of trouble. After browsing on the internet I found that it is best to leave it at 0.0.0 and have KNXD assign the address by itself.

Once the connection has been made with KNXD, it is possible to set up a KNX Device. My device is a KNX switch.
Select the right bridge to communicate with. Normally there will only be one bridge, which is the one we just set up with KNXD.

The address, is the individual address of your KNX device. OpenHAB will poll this address to see if the device is up and running on the bus. If you just want to send messages on the bus and not have OpenHAB poll your actuator on the bus, leave the Address blank.
Here you don't have to define yet what your device does. That is done by assigning channels.

Once both of these are set up, OpenHAB should show them as online:

When everything shows up as online it means that OpenHAB is able to reach everything on the KNX bus. The hardware part is mostly done here now. This means all the hardware is working properly and the software can interact with it.

Assigning group addresses to communicate on the bus, is done by clicking on your device and adding a channel. The channel can be a switch, blind,...

Every channel gets assigned a group address and can then be assigned to a control element in the HABPanel or some other UI in OpenHAB.

In the control tab you can control your newly assigned channel. This is only used for testing. Controlling your installation is done through one of the OpenHAB UIs you can build. If you push the button next to your element you should see some messages appearing on the KNX bus. On the image below you can see the on/off commands being sent.

The messages that come before the on/off commands, are coming from OpenHAB. They are used by OpenHAB to poll the status of your device. This is then used to show in the UI if the device is online or not.

As now everything is working, I'll look into making a step by step guide on how to set everything up.

Discussions