EKBPRO KNX Terminal Python – an open-source KNX SCADA in the terminal, with an OPC UA bridge to CODESYS on WAGO PFC

Hi all,

I’d like to share an open-source project I’ve been building: **EKBPRO KNX Terminal Python**, a SCADA and visualisation for KNX that runs in the terminal and is used over SSH. It runs in Docker on a WAGO PFC200/PFC300, and it has an OPC UA bridge so a C
ODESYS program can read and write KNX group addresses.

**GitHub:** GitHub - espenbo/ekbpro-knx-terminal-python: KNX visu for the terminal · GitHub (GPL-2.0, Python 3.11+)

Why a terminal?

I wanted an old-school operator station: green text, function keys, no browser, no per-tag licence. Everything is built automatically from the **ETS project file** (`.knxproj` / `.knxprojarchive`): floors, rooms, cards with switches, dimmers, setpoints
and operating modes, the DPTs and the read/write flags. Point it at your ETS export and your KNX IP interface, and you have a working visualisation in a few minutes.

It’s built on [xknx](GitHub - XKNX/xknx: XKNX - A KNX library written in Python · GitHub) / xknxproject for KNX and [Textual](https://textual.textualize.io/) for the UI.

What it does

  • **Rooms and floors** with live status and operation (F2), a **floor plan** with live room status (F8, exportable to DXF)
  • **Group address browser** with live values, read and write (F3)
  • **Bus monitor** with filter and pause (F4)
  • **Alarms** from simple rules in the config, with acknowledgement and history (F5)
  • **Event log**: who operated what, and when, also over SSH (F6)
  • **Trends** from the built-in SQLite log, 1 hour to 30 days (F7)
  • **One server, many clients**: one KNX tunnel no matter how many SSH sessions are open, logging around the clock
  • KNX IP **tunnelling** (UDP/TCP), **routing** and **KNX IP Secure** with a keyring from ETS
  • **Several KNX IP interfaces** at once (one per line or building part, with routing and de-duplication), and **several ETS projects** in one site
  • English and Norwegian UI, five colour themes (including green and amber phosphor)

Running it on a WAGO PFC

The PFC300 (750-8302) has Docker but no Python, so the program ships as a container. Enable Docker in the web-based management (*Configuration → Docker*). I’ve tested it on firmware 04.08.09 (aarch64, Docker 25). All dependencies install as prebuilt wh
eels, so no compiler is needed on the PLC.

```sh
cd /home
curl -L https://github.com/espenbo/ekbpro-knx-terminal-python/archive/refs/heads/main.tar.gz | tar xz
cd ekbpro-knx-terminal-python-main
docker build -t ekbpro-knx .

create config.yaml from your ETS project (the project and data live in /home/knx on the PLC)

docker run --rm -v /home/knx:/data ekbpro-knx init /data/MyHouse.knxproj --gateway 192.168.1.50

–cpus/–memory: CODESYS must always get enough CPU – the server needs far less

docker run -d --name knx --restart unless-stopped --network host \
–cpus 1 --memory 512m -v /home/knx:/data ekbpro-knx

open the visualisation from an SSH session on the PFC

docker exec -it knx knx
```

Full guide: [docs/09-docker.md](ekbpro-knx-terminal-python/docs/09-docker.md at main · espenbo/ekbpro-knx-terminal-python · GitHub)

KNX ↔ CODESYS over OPC UA

This is probably the most interesting part for this forum. The server is an **OPC UA client of the PLC’s own CODESYS OPC UA server**. You don’t need an OPC UA client licence or an extra port on the PLC, and the PLC program needs no KNX library or KNX terminal. It just reads and writes variables in a GVL:

```
KNX bus ── KNX IP interface ── KNX Terminal Python ── OPC UA ── CODESYS (GVL_KNX)
```

  1. `./scada plc-map` creates a mapping file from the ETS project, with one line per group address. You pick the addresses the PLC needs (`use: true`), or all of them, and the direction for each: `to_plc` (temperatures, feedback), `to_knx` or `both` (se
    tpoints, lights).

  2. It also **generates the CODESYS GVL** (`GVL_KNX.st`) with the right IEC types from the DPTs: BOOL, REAL, USINT for HVAC mode, and so on. It includes `{attribute ‘linkalways’}` and `{attribute ‘symbol’ := ‘readwrite’}`, so the GVL shows up in the Sym
    bol Configuration even before any code uses it:

    ```
    VAR_GLOBAL
    GA_0_1_0_Outdoor_temp : REAL; // 0/1/0 to_plc Outdoor temp (9.001)
    GA_1_1_5_Hall_light_switching : BOOL; // 1/1/5 both Hall light switching (1.001)
    GA_3_1_0_Living_setpoint : REAL; // 3/1/0 both Living setpoint (9.001)
    END_VAR
    ```
    If the PLC already has its own KNX objects in ETS named with a system tag, for example `564_002_RT6101`, the variables can be named after the tag instead (`plc.tag_prefix`).

  3. Paste the GVL into your project, tick it in the Symbol Configuration, download, and set `plc.enabled: true`. The bridge finds the GVL by browsing, so you don’t need to type any node IDs.

**Safety rules, because this writes to a real bus:**

  • **No telegrams at start-up.** When the bridge connects, it writes the last known KNX values *to the PLC*. The PLC’s current values are only noted, and only real *changes* made by the PLC program go to KNX.
  • **No telegrams when the PLC restarts.** A download or reset sets the GVL back to FALSE/0 while the OPC UA session may stay up. The bridge recognises this in three ways and sends nothing: values reported without Good status, many variables changing at
    once, and a quiet period after a restart. When the quiet period is over, it re-syncs the PLC from KNX. (I learned this one the hard way: one download switched off every light in my house.)
  • **No echoes, and a rate limit** per address towards KNX.
  • **Security:** user name/password and signed or encrypted connections (Basic256Sha256, Aes128Sha256RsaOaep, Aes256Sha256RsaPss), with a client certificate that is created automatically. Every PLC write to KNX appears in the event log as user `plc`.

Details: [docs/10-plc-opcua.md](ekbpro-knx-terminal-python/docs/10-plc-opcua.md at main · espenbo/ekbpro-knx-terminal-python · GitHub)

Try it without a KNX installation

```sh
git clone GitHub - espenbo/ekbpro-knx-terminal-python: KNX visu for the terminal · GitHub
cd ekbpro-knx-terminal-python
./setup.sh
./scada init ~/MyHouse.knxproj # any ETS export
./scada server --demo & # simulated bus
./scada
```

Feedback welcome

It runs in my own house (one KNX IP interface, a PFC300 with CODESYS) and in an office building with two IP routers. I’d love to hear from anyone who tries it with other WAGO controllers or CODESYS versions. Issues and pull requests are welcome on GitHub.

A tip for iPhone users: use a terminal app with full xterm support, such as Blink Shell or Termius. Very basic terminal apps can’t show full-screen terminal programs.

Thanks to the xknx, Textual and asyncua projects, which do the heavy lifting.