Skip to main content

A pure Python async client for KNXD's (EIBD's) native Layer 4 KNX protocol.

Project description

KNXDclient

A pure Python async client for KNXD's (EIBD's) native Layer 4 KNX protocol.

EIBD is a *NIX daemon for routing EIB/KNX telegrams through various interfaces and programmatically accessing the EIB/KNX bus. It's part of the no-longer maintained BCUSDK. However, there's a fork called KNXD, which is still actively maintained.

This package reimplements small parts of the EIBD client (see BCUSDK documentation, section 7.7) in pure Python 3, based on asynchronous coroutines (asyncio). Currently, it allows to open a Group Socket for sending and receiving KNX telegrams to/for any group address via KNXD. Additionally, this package includes helper methods encode_value() and decode_value() to convert the send/received data from/to native Python types according to a known KNX Datapoint Type (DPT).

Usage example

import asyncio
import knxdclient


async def handler(packet: knxdclient.ReceivedGroupAPDU) -> None:
    print("Received group telegram: {}".format(packet))

async def main() -> None:
    connection = knxdclient.KNXDConnection()
    connection.register_telegram_handler(handler)
    await connection.connect()
    # Connection was successful. Start receive loop:
    run_task = asyncio.create_task(connection.run())
    # Now that the receive loop is running, we can open the KNXd Group Socket:
    await connection.open_group_socket()

    # Startup completed. Now our `handler()` will receive incoming telegrams and we can send some:
    await connection.group_write(knxdclient.GroupAddress(1,3,2),
                                 knxdclient.KNXDAPDUType.WRITE,
                                 knxdclient.encode_value(True, knxdclient.KNXDPT.BOOLEAN))

    await asyncio.sleep(5)
    # Let's stop the connection and wait for graceful termination of the receive loop:
    await connection.stop()
    await run_task


asyncio.run_until_complete(main())

License

This package is published under the terms of the Apache License 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knxdclient-0.3.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

knxdclient-0.3.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file knxdclient-0.3.1.tar.gz.

File metadata

  • Download URL: knxdclient-0.3.1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for knxdclient-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5bfc27de94c68f510d9e36ad99dbec7b0b6712ee1c58f29b625c163291aec98e
MD5 fc456b654d3425f91725d6e5afce8768
BLAKE2b-256 c3a124d749038ab9b3f0ca261f377e2d634d55b37ef2045aec255b1be2f4a961

See more details on using hashes here.

File details

Details for the file knxdclient-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: knxdclient-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for knxdclient-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1fd329d6facdf1ac89b9b6fcf5b594a66d82ba8ef62576140220d6764bce58f
MD5 23e36256def7960840522ab22add2a5d
BLAKE2b-256 1d5e9944432a8dec817826f79b347407c516ec79cbf06e081c4265e0f8fdb81d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page