Skip to content

XKNX/xknx

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a8ec9f0 · May 13, 2024
Feb 2, 2024
Mar 5, 2024
Feb 5, 2024
May 13, 2024
Feb 2, 2023
Mar 5, 2024
Apr 22, 2024
Apr 7, 2021
Dec 17, 2021
Apr 13, 2023
Apr 15, 2024
Sep 10, 2017
Feb 28, 2021
Feb 5, 2024
Jan 10, 2023
Feb 26, 2024
Feb 5, 2024

Repository files navigation

XKNX - An asynchronous KNX library written in Python

PyPI - Python Version codecov Checked with mypy Pre-commit HA integration usage Discord

Documentation

See documentation at: https://xknx.io/

Help

We need your help for testing and improving XKNX. For questions, feature requests, bug reports either open an issue, join the XKNX chat on Discord or write an email.

Development

You will need at least Python 3.9 in order to use XKNX.

Setting up your local environment:

  1. Install requirements: pip install -r requirements/testing.txt
  2. Install pre-commit hook: pre-commit install

Testing

To run all tests, linters, formatters and type checker call tox

Running only unit tests is possible with pytest Running specific unit tests can be invoked by: pytest -vv test/management_tests/procedures_test.py -k test_nm_individual_address_serial_number_write_fail

Home-Assistant

XKNX is the underlying library for the KNX integration in Home Assistant.

Example

"""Example for switching a light on and off."""
import asyncio

from xknx import XKNX
from xknx.devices import Light


async def main():
    """Connect to KNX/IP bus, switch on light, wait 2 seconds and switch it off again."""
    async with XKNX() as xknx:
        light = Light(xknx,
                      name='TestLight',
                      group_address_switch='1/0/9')
        await light.set_on()
        await asyncio.sleep(2)
        await light.set_off()

asyncio.run(main())

Attributions

Many thanks to Weinzierl Engineering GmbH and MDT technologies GmbH for providing us each an IP Secure Router to support testing and development of xknx.