knxd, OpenHab, Raspberry Pi, Vimar by Me

Playing with those tools is a good way to get crazy but is even funny, after all.

This notes are not necessarily connected to the home automation by Vimar, but I’ve faced the problem with this kind of bus.

I’m using an USB device to connect the Rapsberry Pi to the automation bus.

The problem was this: using the knxtool from a Raspberry Pi, I was able to turn on and off a light. The tool installed automatically with the knxd (0.14) package in a “openHABian” distribution.

Sending the identical commands with openHAB there was no way to switch the light.

In short: the openHAB KNX/IP Gateway was configured with the same address set on kndx deamon configuration (in my case 1.1.128). As soon as I changed the KNX address in openHAB to a different address (3.1.1 – absolutely random) everything started to work.

About kndx

knxd can be configured to listen as UDP and as TCP. UDP is on port 3671 while TCP is on port 6720.

openHAB can connect only with UDP, while knxtool uses TCP. Be aware of this different since I have not found that documented (so I lose a lot of time trying to set openHAB to use the port 6720).

Configuring knxd is still something of magic to me, so I don’t share my configuration since it is just as I left it when it started to work!

Enabling logging

To try to find our what was not working, being openHAB written in Java and using slf4j, I hoped my 20 years in Java development could have helped me. Not exactly… anyway I finally worked out to have everything logged out of the KNX traffic and internal events.

Edit the file /var/lib/openhab/etc/log4j2.xml and add:

<Logger level="DEBUG" name="calimero">
<AppenderRef ref="KNX"/>
<Logger level="DEBUG" name="p.KNXnet">
<AppenderRef ref="KNX"/>

just after the line

<Logger level="INFO" name="org.openhab"/>

and the block

<RollingFile fileName="${sys:openhab.logdir}/knx.log" filePattern="${sys:openhab.logdir}/knx.log.%i" name="KNX">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
<SizeBasedTriggeringPolicy size="16 MB"/>

where you find other RollingFile appenders.

All that creates new file in the /var/log/openhab folder named knx.log. If you keep an eye on that file using tail, you can see all messages from the bus.

tail -f /var/log/openhab/knx.log

Note: in some threads or documentation pages (I don’t remember) you can find that is enough to log defining a logger for but that does not work since the KNX libraries does not use common conventions for logger names.

Leave a Reply