KNXnet/IP
KNXnet/IP is the IP tunnelling and routing extension of KNX, the field bus used in home and building automation for lighting, heating, shutters and similar building services. Devices exchange telegrams addressed to group addresses over the bus; the driver reaches that bus through a KNXnet/IP interface on the IP network.
Supported Operations
| Name | Value | Description |
|---|---|---|
|
Go and Java. Reads the value of a group address. Requires the datapoint type to be
known, either from a |
|
|
Go and Java. Writes the value of a group address. Requires the datapoint type, same
as |
|
|
Go and Java. Subscribes to telegrams on the bus. Each address segment may use a wildcard, so subscriptions can span a whole line, a whole room, or a whole datapoint across the installation. |
|
|
Go and Java, with different results. Java lists the group addresses known to a loaded ETS project, filtered by a browse query. Go connects live to devices on the bus, either enumerating them by KNX individual address (a device query) or listing a connected device’s communication objects (a communication object query). |
Connection String
The KNXnet/IP connection string has the following format:
knxnet-ip://{ip-address}[:{port}]?{options}
udp is the only supported transport and is the default, so it is omitted from the
connection string. The port defaults to 3671:
knxnet-ip://192.168.42.28
Connection String Options
Name |
Type |
Default Value |
Required |
Description |
Name |
KNXNet/IP |
|||
Code |
|
|||
Maven Dependency |
<dependency> <groupId>org.apache.plc4x</groupId> <artifactId>plc4j-driver-knxnetip</artifactId> <version>1.1.0</version> </dependency> |
|||
Default Transport |
|
|||
Supported Transports |
|
|||
Config options: |
||||
|
FILE |
Path to the |
||
|
STRING |
Optional password needed to read the knxproj file. |
||
|
INT |
3 |
KNX Addresses can be encoded in multiple ways. Which encoding is used, is too not provided by the protocol itself so it has to be provided externally: |
|
|
STRING |
LINK_LAYER |
Type of connection used to communicate. Possible values are: |
|
|
INT |
10000 |
Maximum time (in milliseconds) to wait for a reply during the KNXnet/IP search, connect and tunnelling exchanges. |
|
Transport config options: |
||||
udp |
||||
|
STRING |
Local address to bind to. If not set, binds to all interfaces. |
||
|
INT |
0 |
Local port to bind to. 0 uses ephemeral port. |
|
|
INT |
0 |
Socket read timeout in milliseconds. 0 means no timeout. |
|
|
INT |
65507 |
Maximum UDP packet size in bytes. |
|
|
INT |
0 |
Send buffer size in bytes. 0 uses system default. |
|
|
INT |
0 |
Receive buffer size in bytes. 0 uses system default. |
|
|
BOOLEAN |
false |
Enable SO_BROADCAST for sending broadcast packets. |
|
|
BOOLEAN |
false |
Enable SO_REUSEADDR to allow multiple bindings to the same address/port. |
|
|
BOOLEAN |
false |
Share the underlying UDP socket across multiple transport instances. When true, instances with the same localAddress:localPort will share a socket. This is useful for protocols where multiple logical connections share one UDP port. |
|
|
INT |
1 |
Time-to-live for multicast packets (1-255). |
|
Tag Addresses
Addressing is implemented in Go and Java. See the protocol support matrix for what each implementation does.
General Format
A tag names a KNX group address, using one of three levels of structure, optionally suffixed with a datapoint type:
{main-group}
{main-group}/{sub-group}
{main-group}/{middle-group}/{sub-group}
{address}:DPT{main}[.{sub}]
| Name | Description |
|---|---|
1-level address |
|
2-level address |
|
3-level address |
|
DPT suffix (optional) |
|
Which of the three level counts is expected is controlled by the
group-address-num-levels connection string parameter, or by the levels recorded in a
loaded knxproj-file-path project.
Go additionally accepts a bracketed list or range in any segment, such as
1/2/[3,4] or 1/[1-3]/. Java’s parser only ever accepts a bare digit run or a lone
in each position; 1/2/[3,4] is rejected by Java. This page documents the Java
syntax - consult the Go driver’s own source for what it accepts.
|
Datapoint Type Suffix
An address may carry an optional datapoint-type suffix :DPT{main}[.{sub}], which tells the driver
how to interpret the value on the wire:
1/2/3:DPT9.001
The KNX protocol does not transport the datatype of a group address, so the driver has to get it
from somewhere. If no knxproj-file-path is configured, this suffix is required for reading and
writing - a request for a plain 1/2/3 fails because the datapoint type cannot be resolved.
Browsing likewise requires a knxproj-file-path.
However, when subscribing for events, each segment allows use of the wildcard character *.
If the addresses used in the KNX installation are structured, this makes it possible to,
for example (depending on the scheme used):
-
Collect all information for a given level of your building:
1// -
Collect all information for a given room:
2/4/* -
Collect all information about heating in all rooms:
//50
| Don’t use wildcards when explicitly reading or writing data - this is only supported when subscribing to events. |
Data Types
The value on the wire is interpreted using a KNX Datapoint Type (DPT), identified as
DPT{main}[.{sub}] - for example DPT1 (1-bit boolean), DPT5 (8-bit unsigned) or
DPT9.001 (2-byte float, temperature in °C). The datapoint type comes from the :DPT…
tag suffix when present, and otherwise from the group address’s entry in a loaded
knxproj-file-path ETS project. When a sub-number is not given in the suffix (DPT9
rather than DPT9.001), the driver resolves it to the first sub-type registered under
that main number.
Notes and Tips
Browse Queries
browse takes a separate query syntax, not a tag address: each of the three levels may
be a literal number or the wildcard , and the whole query may itself be or **
to mean everything.
| Query | Meaning |
|---|---|
|
every group address |
|
every group address under main-group 1 |
|
every group address under main-group 1, middle-group 2 |
|
exactly group address |
|
every group address with middle-group 2, sub-group 3 |