Network API| With this function block the controller provides a
simple, open interface for third-party devices and programs – for
example an energy management system, Home Assistant, Node-RED, your
own application or a script. Over a TCP connection the values of all
variables in the address list can be read and written, either via a
simple text protocol or via HTTP.
The Network API is the documented interface for third-party devices. Port 10001, which Studio and APP use to talk to the controller, is not intended for this: its protocol is encrypted, not published and may change with any version. The block is created on a program page like any other function block; set port and protocol and transfer the project to the controller. Several Network API blocks with different ports are possible, e.g. one for the text protocol and one for HTTP. |
Outputs |
||
| AC |
Number of clients |
Number of currently connected clients, updated every
second. At most 32 connections are possible at the same time. With
the HTTP protocol a connection is only open for the duration of one
request, so the value is usually 0. |
Parameters |
||
| Port |
TCP port on which the controller accepts connections
(1 to 65535, default 9090). The port must not be used by another
service of the controller, e.g. 10001 (Studio/APP), 80/443 (web
interface) or 502 (Modbus slave). |
|
| Protocol |
|
|
Commands |
||||||||||||
Each command consists of an address from the address
list, an equals sign and a value or a question mark.
Addresses: The addresses of the address list in the Studio apply, three-level in the form main group/middle group/sub group, e.g. 3/1/0. A dot is also accepted as separator
(3.1.0), a two-level address (3/256) is
converted as in the ETS. The controller always answers three-level
with slashes. KNX group addresses are accessible as well as internal
variables. An address that does not exist in the address list is
ignored and noted in the controller log – there is no error
response.Values: Numbers are transferred with a dot as decimal separator. In responses they always have six decimal places, e.g. 1.000000 for on and 0.000000 for off. When
writing, 1 or 21.5 is sufficient. Text
variables (EIS 15 Zeichenkette) are transferred as plain text;
the text itself may contain an equals sign. All other values are
passed as numbers, the controller converts them into the KNX format
(e.g. 2-byte float). Time, date and colour values are not supported
by the Network API.Line end: In the text protocol each command must be terminated with LF (\n), an additional CR (\r) is ignored. Every response line ends with LF. A line may be at most 1023 characters long. |
||||||||||||
Reading |
||||||||||||
| A read command returns the value the controller
currently holds for this variable. No telegram is sent on the
KNX bus and nothing in the project is changed. The value is the last
one received or sent – for a KNX address, the value of the last
telegram the controller has seen on the bus. A client that only reads sends only commands with ?.
The interface itself has no read-only mode, see "Security". |
||||||||||||
Writing |
||||||||||||
| A write command has the same effect as operating the
value in the APP: the controller takes over the value into the
variable, linked function blocks react to it, and if the address is
a KNX group address a write telegram is sent on the KNX bus. For an
internal variable the value stays in the controller. The controller does not report whether an actuator has executed the command. To check this, query the feedback address of the actuator or wait for its change message in the text protocol. |
||||||||||||
Change messages (text protocol only) |
||||||||||||
With the text protocol there is no need for cyclic
polling. As long as the connection exists, the controller sends
every value change of a variable unsolicited to all connected
clients, in the same format as a response, e.g.
3/0/0=21.400000. This applies to telegrams from the KNX
bus as well as to values from function blocks, the APP or other
interfaces. Values written by a client via the Network API itself are
not reported back to the clients.There is no selection of individual addresses – the client receives all changes and filters them itself. The usual approach: after connecting, send ? once to get the initial state, then
only evaluate the change messages.With the HTTP protocol no changes are reported; here polling is required. |
||||||||||||
Examples |
||||||||||||
Text protocol, e.g. with netcat (finish each input
with Enter):
nc 192.168.1.90 9090 3/0/0=? 3/0/0=21.340000 3/1/1=? 3/1/1=1.000000 3/0/0=21.400000 <- change message, unsolicitedHTTP, e.g. with curl or in the browser: curl "http://192.168.1.90:9090/?3/0/0=?" 3/0/0=21.340000 curl "http://192.168.1.90:9090/??" 1/1/0=0.000000 ... ?=FINISHED curl "http://192.168.1.90:9090/?3/0/3=21.5"In the HTTP call, spaces and special characters must be encoded as usual ( %20 for a space). Several commands in one call
are separated by %0A, e.g.
/?3/0/0=?%0A3/0/4=?. The response is plain text
(text/plain, UTF-8).Python, text protocol with change messages: import socket
s = socket.create_connection(("192.168.1.90", 9090))
s.sendall(b"?\n") # initial state
buf = b""
while True:
buf += s.recv(4096)
while b"\n" in buf:
line, buf = buf.split(b"\n", 1)
addr, value = line.decode().split("=", 1)
print(addr, value)
|
||||||||||||
Security |
||||||||||||
The Network API has no login and no
encryption. Every device that can reach the configured port can
read and write all variables – and thus, via KNX addresses, also
switch heating, hot water, shading or door openers. Therefore:
|
||||||||||||
Limits |
||||||||||||
|
Frequently asked questions on connecting third-party systems |
||||||||||||||||||
Which interface is intended for a third-party system?For reading and writing variables, this Network API is the open, documented interface. In addition there are MQTT addresses I/O (variables as MQTT topics, e.g. for Home Assistant, ioBroker or Node-RED) and the Modbus TCP slave. Port 10001 belongs to Studio and APP; its protocol is not published and not released for third-party systems.All these interfaces are function blocks. They only become active once they have been created in the project and the project has been transferred to the controller – none of them can be switched on without a transfer. Therefore always start from the project version currently running in the controller (see "Project with an older Studio" below). Does the Network API need a licence or activation?No. The Network API does not require a licence option of its own; it is available on every controller that runs a program.How does a third-party system log in?Not at all – there is no user, no password and no encryption. Anyone who can reach the port has access. Protection must be provided by the network, see "Security".Is read-only access possible?Read commands (…=? and ?) change nothing and
send no KNX telegram. However, there is no way to block write access:
whether only reading takes place is up to the third-party system.
Only a command with a value (3/1/0=1) writes.
Are there push messages on value changes?Yes, with the text protocol all changes are sent automatically, see "Change messages". With HTTP, polling is required.Are there test tools or examples?netcat, curl or a browser are sufficient for testing, see "Examples". To try out a third-party system safely, start by only reading. Invalid commands and addresses missing from the address list are noted in the controller log.Which KNX data type applies to a variable?The data types in the Studio are named after the old EIS numbering, not after the KNX DPT number, and they are shown in German in every language. The number in the name is therefore not the DPT main number:
Via the Network API the byte encoding does not matter: values are transferred as plain-text numbers ( 21.500000), the
controller converts them into the KNX format. The DPT is only needed
if a third-party system listens directly on the KNX bus.
Can addresses and data types be exported?Yes, in the Studio via "Edit – Addresses ODBC Export", either all or only the selected addresses. Available formats are the XML format of the ETS group address export (name, address, DPT) and the ESF format (text file with group names, address, comment and data type). Links to function blocks and control elements are not exported.Can the controller's KNX interface be used as a KNXnet/IP interface?Controllers with a built-in KNX interface include an internal KNX IP gateway. As long as it is switched off, UDP port 3671 cannot be reached. It is switched on in the Studio under "Control – Services" or in the web interface. In the KNX interface block the type "KNX-IP Gateway onboard" must be set for this.
Can the Modbus TCP slave be used for a third-party system?Yes. Create a Modbus TCP slave block and link the variables that are to be available as registers to its inputs. Port 502 is only open once such a block exists in the project. Register assignment and function codes are described in the help of the block.Project with an older Studio: "Unknown function block"If the Studio shows "Unknown function block" when opening a project, the Studio is older than the project and does not know this block yet. These are not customer-specific blocks.
|