erijo / tellive-py

Python wrapper for Telldus Live
GNU General Public License v3.0
12 stars 8 forks source link

Python wrapper for Telldus Live

.. image:: https://badge.fury.io/py/tellive-py.png :target: https://pypi.python.org/pypi/tellive-py/

.. image:: https://secure.travis-ci.org/erijo/tellive-py.png?branch=master :target: http://travis-ci.org/erijo/tellive-py

tellive-py is a Python wrapper for Telldus Live <http://live.telldus.com/>_, "a user friendly service for automating your TellStick connected gear using the Internet".

Please report any problem as a GitHub issue report <https://github.com/erijo/tellive-py/issues/new>_.

Features

Requirements

Installation

.. code-block:: bash

$ pip install tellive-py

Example

To run the included program for connecting a TellStick to Telldus Live:

.. code-block:: bash

$ tellive_core_connector ~/.config/tellive.conf

The first time you run the program (with a particular config file), it will exit and ask you to visit a given URL to give the program access to your account.

When you have done so, you can then edit the config file (~/.config/tellive.conf in this example) and add a name to the sensors that you wish to send to Telldus Live. You can also disable devices that you don't want to be controllable via Telldus Live (see tellive_core_connector --help for more info). Then start the program again as above.

The program runs well as a background process in e.g. screen <http://www.gnu.org/software/screen/>_. To have it automatically start after boot, you can add the following to your crontab (crontab -e). The two lines that set PYTHONPATH and PATH are only needed if you haven't installed the modules, only cloned the repositories or unpacked the tar ball (replace /home/erik with the correct path):

.. code-block:: bash

PYTHONPATH = /home/erik/tellive-py:/home/erik/tellcore-py
PATH = /home/erik/tellive-py/bin:/usr/bin:/bin

@reboot screen -dmS tellive tellive_core_connector ~/tellive.conf

API example

The API can also be used by your own program. This how you would connect to Telldus Live and register the client (with PUBLIC_KEY and PRIVATEKEY from here <http://api.telldus.com/keys/index>):

.. code-block:: python

client = TellstickLiveClient(PUBLIC_KEY, PRIVATE_KEY)
(server, port) = client.connect_to_first_available_server()
client.register(version="0.1")