KNX - fcorthay/xPL GitHub Wiki

KNX is a standard commercial and residential building automation. The physical installations can use several links:

  • twisted pair wiring
  • power-line networking
  • radio
  • Ethernet

Table of Contents

KNX service

Install knxd:

sudo apt install -y knxd knxd-tools

Check the components:

cat /lib/systemd/system/knxd.socket
cat /lib/systemd/system/knxd.service

With an IP router, find its IP address and edit /etc/knxd.conf (adapt the address):

#KNXD_OPTS="-e 0.0.1 -E 0.0.2:8 -u /tmp/eib -b ip:"
KNXD_OPTS="-e 0.0.1 -E 0.0.2:8 -u /tmp/eib -b ipt:192.168.1.204"

Restart the service:

sudo service knxd restart

Listen to the KNX bus:

knxtool list
knxtool groupsocketlisten ip:localhost

Write on the KNX bus:

knxtool groupswrite ip:localhost 1/1/1 1
knxtool groupswrite ip:localhost 1/1/1 0

Python library

The knx python library allows to send and to listen to telegrams with the help of the KNX service.

Install the library:

sudo pip install knx --break-system-packages

In order to test it, write the following script and run it:

#!/usr/bin/python3
from knx import connect
with connect() as c:
    c.write('1/1/1', 1)

XPL services

For the connection to KNX, there are two xPL services:

  • xpl-knxRead.pl which reads the output of groupsocketlisten and forwards them as xPL messages
  • xpl-knxWrite.pl

KNX reader

Test the reader:

XPL_BASE_DIR=~/Controls/xPL
knxtool groupsocketlisten ip:localhost | $XPL_BASE_DIR/lights-blinds/xpl-knxRead.pl -v

KNX writer

Launch the writer in a first terminal:

XPL_BASE_DIR=~/Controls/xPL
$XPL_BASE_DIR/lights-blinds/xpl-knxWrite.pl -v

Send commands in another terminal:

XPL_BASE_DIR=~/Controls/xPL
$XPL_BASE_DIR/xPL-base/xpl-send.pl -v -t cmnd -c knx.basic group='1/1/1' data=0x01
$XPL_BASE_DIR/xPL-base/xpl-send.pl -v -t cmnd -c knx.basic group='1/1/1' data=0x00

Launching at startup

If required, update the paths in the provided service files xpl-knxRead.serviceand xpl-knxWrite.service.

Define and start the services:

XPL_BASE_DIR=~/Controls/xPL
SERVICE='xpl-knxRead'
sudo cp $XPL_BASE_DIR/services/$SERVICE.service /lib/systemd/system/
sudo systemctl enable $SERVICE.service
sudo service $SERVICE start
service $SERVICE status | cat

SERVICE='xpl-knxWrite'
sudo cp $XPL_BASE_DIR/services/$SERVICE.service /lib/systemd/system/
sudo systemctl enable $SERVICE.service
sudo service $SERVICE start
service $SERVICE status | cat
⚠️ **GitHub.com Fallback** ⚠️