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.
- … 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.
- … provides Heartbeat monitoring for Tunneling connections + clean reconnect if KNX/IP connection failed.
- … does clean connect and disconnect requests to the tunneling device.
- … ships with Home Assistant.
XKNX depends on Python >= 3.7
You can install XKNX as Python package via pip:
pip install xknx
import asyncio from xknx import XKNX from xknx.devices import Light async def main(): xknx = XKNX() await xknx.start() light = Light(xknx, name='HelloWorldLight', group_address_switch='1/0/9') await light.set_on() await asyncio.sleep(2) await light.set_off() await asyncio.sleep(2) await xknx.stop() asyncio.run(main())
For more examples please check out the examples page