Command Line Interface
Installing xknx puts an xknx command on the path (also available via python -m xknx). Run xknx --help or xknx <command> --help for all options.
Discover gateways
Searches all network interfaces for KNX/IP gateways and prints their addresses and capabilities. Exits non-zero when nothing was found.
xknx scan
xknx scan --local-ip 10.0.100.49 --timeout 5
Group communication
The group commands connect to the KNX installation - by gateway discovery, or through a specific gateway with --gateway (UDP tunneling).
Read a group address value once and print it:
xknx group read 1/2/3
xknx group read 1/2/3 --type temperature
Write a value to a group address and wait for the bus confirmation. Without --type, on/off and raw integers 0-63 are sent as 1-bit or 6-bit payloads, and 0x-prefixed raw bytes like 0x0c33 - as printed by group read - are sent as a raw payload; with --type, the value is encoded by that datapoint type. Structured datapoint types take a JSON object; string datapoint types take the value as literal text:
xknx group write 1/2/3 on
xknx group write 1/2/3 21.5 --type temperature --gateway 10.0.0.10
xknx group write 1/2/3 '{"red": 255, "green": 0, "blue": 0}' --type 232.600
Print group telegrams from the bus until interrupted with Ctrl+C:
xknx group monitor
xknx group monitor --filter '1/2/*' --filter '1/4/5-6,8'
Environment variables
--gateway and --local-ip default to the XKNX_GATEWAY and XKNX_LOCAL_IP environment variables; explicit options take precedence.
export XKNX_GATEWAY=10.0.0.10
xknx group read 1/2/3
Exit codes
0on success1when the command failed (no response, no confirmation, no gateways found, connection errors)2for invalid command line arguments130when interrupted with Ctrl+C