tellcore.library (module)

The classes in this module are not meant to be used directly. They are mostly support classes for the higher level API described in tellcore.telldus (module).

Library

class tellcore.library.Library(name=None, callback_dispatcher=None)[source]

Wrapper around the Telldus Core C API.

With the exception of tdInit, tdClose and tdReleaseString, all functions in the C API (see Telldus Core documentation) can be called. The parameters are the same as in the C API documentation. The return value are mostly the same as for the C API, except for functions with multiple out parameters.

In addition, this class:
  • automatically frees memory for strings returned from the C API,
  • converts errors returned from functions into (TelldusError) exceptions,
  • transparently converts between Python strings and C style strings.
__init__(name=None, callback_dispatcher=None)[source]

Load and initialize the Telldus core library.

The underlaying library is only initialized the first time this object is created. Subsequent instances uses the same underlaying library instance.

Parameters:
  • name (str) – If None than the platform specific name of the Telldus library is used, but it can be e.g. an absolute path.
  • callback_dispatcher – If callbacks are to be used, this parameter must refer to an instance of a class inheriting from BaseCallbackDispatcher.
__del__()[source]

Close and unload the Telldus core library.

Any callback set up is removed.

The underlaying library is only closed and unloaded if this is the last instance sharing the same underlaying library instance.

tdController()[source]

Get the next controller while iterating.

Returns:a dict with the keys: id, type, name, available.
tdSensor()[source]

Get the next sensor while iterating.

Returns:a dict with the keys: protocol, model, id, datatypes.
tdSensorValue(protocol, model, sid, datatype)[source]

Get the sensor value for a given sensor.

Returns:a dict with the keys: value, timestamp.

TelldusError

exception tellcore.library.TelldusError(error, lib=None)[source]

Error returned from Telldus Core API.

Automatically raised when a function in the C API returns an error.

Attributes:
error: The error code constant (one of TELLSTICK_ERROR_* from tellcore.constants).
__str__()[source]

Return the human readable error string.

BaseCallbackDispatcher

class tellcore.library.BaseCallbackDispatcher[source]

Base callback dispatcher class.

Inherit from this class and override the on_callback() method to change how callbacks are dispatched.

on_callback(callback, *args)[source]

Called from the callback thread when an event is received.

Parameters:
  • callback (callable) – The callback function to call.
  • args – The arguments to pass to the callback.

DirectCallbackDispatcher

class tellcore.library.DirectCallbackDispatcher[source]

Dispatches callbacks directly.

Since the callback is dispatched directly, the callback is called in the callback thread.