GithubHelp home page GithubHelp logo

knx's Introduction

knx

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()
>>> coro = knx.bus_monitor(logger(), host='localhost', port=6720)
>>> loop.run_until_complete(coro)

Install & Requirements

  • Python >= 3.6

Install using pip:

$ pip install knx

Disclaimer

I've only tested this with eibd 0.0.5 and the fork knxd 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

Edit knx.py in your favorite editor and run tests using python -m unittest or python tests.py.

If you want to run the examples without first installing this library you can use:

python -m examples.actor -- hostname '0/0/20'

(Replace actor with the appropriate module name and omit the arguments if the module doesn't require them)

knx's People

Contributors

mfussenegger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knx's Issues

Data types

I have started trying out the examples. It seems to me that the Async example does not handle some data types correctly.

One example of the percentage data type. From ETS:

telegram

From the example python script:

Telegram(src='2/1/254', dst='0/4/36', value='0')

The value should be $CC or 80%.

The source address appears incorrect, as well.

/Per

Sync Read how should it work

Hi there, in the doc string of Connection.read it is written that this function would send all Received Telegrams to a knx listener, but in the Connection class you can't pass such a listener nor can you create such an instance? Can you explain in more detail how this is supposed to work.

Thanks a lot in advance :)

Sintax error while compiling in c9.io

Hi,
Trying to make a simple telegram bot for controlling my house and using c9.io as workspace
When installing the libraries get the following error:

`jujonet:~/workspace $ sudo pip install knx
Downloading/unpacking knx
Downloading knx-0.3.0-py2.py3-none-any.whl
Installing collected packages: knx
Compiling /tmp/pip_build_root/knx/knx.py ...
File "/tmp/pip_build_root/knx/knx.py", line 237
data = yield from reader.read(100)
^
SyntaxError: invalid syntax

Successfully installed knx
Cleaning up...`

Not sure if this is just related to cloud9.

Regards

Julio

Does this support DPT encoding?

Let's assume I have a local humidity sensor and want to send this as DPT5 or a temperature value as DPT9?

I'm pretty new to Python, so no idea if there are other libraries our there or if this is implemented. However, when I look into the code I don't see and DPT conversion modules.

Thanks...

knx write

hallo,
ist es möglich mit deinem plugin ein dpt 16.00 (ASCII) an den bus zu senden!
bei mir läuft das immer in einen fehler, auch wenn ich vorher korrekt in ein bytearray umrechne und dieses der write funktion übergebe!

How can I calculate these values?

How can I calculate the decimal value of a 2 bytearray.
As input I get a bytearray (first part of the equation) = result from 'telegram_logger.py
I parse this into 2 bytes (middle part of the equation).
I know what the results are from ETS (last part of the equation).

bytearray(b'\x11\xc7') = b'11c7' = 18.2
bytearray(b'\x07\x1b') = b'071b' = 18.19
bytearray(b'>Y') = b'3e59' = 2080
bytearray(b'>Z') = b'3e5a' = 2081.28

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.