Skip to main content

KNX / EIB library

Project description

travis-ci Wheel PyPI Version Python Version

A minimalistic KNX / EIB python library.

Sending telegrams

This library can be used to send data telegrams to actuators in the bus system.

For example in order to turn on a light the following code could be used:

>>> from knx import connect
>>> with connect() as c:
...     c.write('0/1/14', 1)

Where 0/1/14 is the address of the light and 1 is the payload of the data telegram which indicates that the light should be turned on.

Listening to telegrams

This KNX library can also be used to listen to telegrams that are sent onto the bus system. For example if you simply want to log an entry each time a light is turned off or on:

>>> import knx
>>> import asyncio

>>> @knx.coroutine
... def logger():
...     while True:
...         telegram = (yield)
...         print('Telegram from {0} sent to {1} with value: {2}'.format(
...               telegram.src, telegram.dst, telegram.value))

>>> loop = asyncio.get_event_loop()
>>> k = knx.AsyncKnx(host='localhost', port=6720)
>>> loop.run_until_complete(k.listen(logger()))

Install & Requirements

  • Python >= 3.4

Install using pip:

$ pip install knx

Disclaimer

I’ve only tested this with eibd 0.0.5 as a gateway.

Alternatives

If you’re looking for complete home automation solutions you might want to take a look at home-assistant or smarthome.

Development

In order to setup a sandboxed development environment use buildout:

  1. Create a virtual environment to have a python without any third-party packages in it’s sys.path: (Kinda Optional):

    python -m venv .venv
  2. Run bootstrap.py:

    .venv/bin/python bootstrap.py
  3. Run bin/buildout:

    bin/buildout

Once these steps are done you’ll be able to run tests using bin/test.

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

knx-0.2.1.tar.gz (10.2 kB view hashes)

Uploaded Source

Built Distribution

knx-0.2.1-py2.py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 2 Python 3

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