XKNX is an Asynchronous Python library for reading and writing KNX/IP packets.
- … does cooperative multitasking via asyncio and is 100% thread safe.
- … provides support for KNX/IP routing and tunneling devices.
- … supports KNX IP Secure - via tunneling or routing.
- … supports KNX Data Secure group communication.
- … has strong coverage with unit tests.
- … automatically updates and synchronizes all devices in the background periodically.
- … listens for all updates of all devices on the KNX bus and updates the corresponding internal objects.
- … has a clear abstraction of data/network/logic-layer.
- … does clean connect and disconnect requests to the tunneling device and reconnects if KNX/IP connection failed.
- … ships with Home Assistant.
XKNX depends on Python >= 3.9
You can install XKNX as Python package via pip:
pip install xknx
import asyncio from xknx import XKNX from xknx.tools import group_value_write async def main(): async with XKNX() as xknx: # send a binary Telegram await group_value_write(xknx, "1/2/3", True) # send a generic 1-byte Telegram await group_value_write(xknx, "1/2/4", [0x80]) # send a Telegram with an encoded value await group_value_write(xknx, "1/2/4", 50, value_type="percent") asyncio.run(main())
For more examples please check out the examples page