Posts in category linux

New ways to script execution from signals

If you have tried to script tasks for TellStick and TellStick Duo you know it is very easy using tdtool. But tdtool is limited to only transmitting signals. What if you want to react on incoming signals from TellStick Duo?

If you want to script execution on incoming signals you either need to script in a third party application such as NexaHome or EventGhost or you need to write your own deamon and listen for callback. Both variants has it quirks. For example you need Windows for EventGhost.

What do you do if you have an headless Linux computer? Or you just don't want the complicated setup with callbacks?

From version 2.1.2 we have added the possibility to add a script to a predefined directory. Any executable script found in those folders will be executed and the parameters are sent as environmental variables. Let's first show an example. Create the file /usr/local/share/telldus/scripts/sensorevent/myscript.sh with the following content and make it executable.

#!/bin/bash
if [ "${DATATYPE}" -eq 1 ]; then
        notify-send --expire-time 3000 "Temperature ${VALUE}°C"
fi

When a sensor is detected the currently temperature will be shown as a popup in my KDE environment.

All callbacks from the C API are available.

/usr/local/share/telldus/scripts/deviceevent/
Environmental variables: DEVICEID, METHOD, METHODDATA
C API equivalent: TDDeviceEvent

/usr/local/share/telldus/scripts/devicechangeevent/
Environmental variables: DEVICEID, CHANGEEVENT, CHANGETYPE
C API equivalent: TDDeviceChangeEvent

/usr/local/share/telldus/scripts/rawdeviceevent/
Environmental variables: RAWDATA, CONTROLLERID
C API equivalent: TDRawDeviceEvent

/usr/local/share/telldus/scripts/sensorevent/
Environmental variables: PROTOCOL, MODEL, SENSORID, DATATYPE, VALUE, TIMESTAMP
C API equivalent: TDSensorEvent

/usr/local/share/telldus/scripts/controllerevent/
Environmental variables: CONTROLLERID, CHANGEEVENT, CHANGETYPE, VALUE
C API equivalent: TDControllerEvent

After adding or removing a script you need to restart telldusd.

For now, this is a Linux only feature. Patches are welcome for other platforms.