LwKnxClient

Cyrille

DEPRECATION NOTICE

This project is now obsolete. As a replacement, I built a comprehensive python package for Linknx named Pyknx.
This package is downloadable at PyPI: https://pypi.python.org/pypi/pyknx

Pyknx offers much more functionalities than the single lwknxclient script. In the package, you will find a script named pyknxclient.py that is the remastered equivalent of lwknxclient. The new script is able to read several objects at once. It notably has support for regular expressions when specifying an object id. And since it is a valid distutils archive, it integrates seamlessly with your Python environment.

Anyway, for history, the former lwknxclient script is still downloadable here but you are strongly encouraged to install the Pyknx package instead.

Below is the old description:

Introduction

This article explains the purpose of a lightweight command line script written in Python that acts as a client for linknx. The goal of this script is to offer a very light alternative to advanced clients like knxweb, in order to provide the user with a straightforward means to build a more complex application that has to communicate with linknx without bothering neither with connection management nor XML parsing.
For now, the script is able to:
- read or write the value of a single object at once
- communicate with a linknx server through TCP using its XML protocol. Server can be local or remote.

Requirements

LwKnxClient is a Python v2 script. Thus it requires the python interpreter. It has been successfully tested against the version 2.7 but other versions may work too.

Download & License

This script is released under the terms of the Gnu Public License version 3.

Syntax

A short help message is displayed when running the script without arguments. The syntax is as follows:

lwknxclient [-h host] [-p port] [-r] [-w value] [-v] OBJECT_ID

Where OBJECT_ID is the identifier of the object as specified in the linknx configuration XML by the 'id' attribute.

Options |
----------------- | -------------------------
-h, --host | Hostname of the machine running the linknx daemon (default is 'localhost').
-p, --port | Port linknx listens on (default is 1028).
-r, --read | Read object's value. Cannot be used in conjunction with the -w option.
-w, --write value | Changes the object's value to the specified value. Cannot be used in conjunction with the -r option.
-v, --verbose | Let the script output useful information, for debugging purpose.

Examples

The following examples assume an installation with:
- linknx running on a machine whose hostname is "homeserver"
- with linknx exposing the following object:

<object type="1.001" id="lights_kitchen" gad="1/0/1" init="request">Kitchen Lights</object>

Then the syntax that lets the script get the status of the lights in the kitchen when script is run on "homeserver" can be:

lwknxclient -r lights_kitchen (since default host is localhost)

The output should be either "on" or "off", according to the value of the object.

If the script is running on a separate machine, the syntax must explicitly define the remote server's hostname:

lwknxclient -r lights_kitchen -h homeserver

LwKnxClient tries to connect to the server on the default 1028 tcp port. Depending on the configuration of linknx, it may be necessary to use a different port:

lwknxclient -r lights_kitchen -h homeserver -p 2000

This command line connects to the 2000 tcp port.

Contact the developer

For any question regarding this script or to report a bug, feel free to contact me at alternate


MongoDB Logo MongoDB