Telldus Live works fine with dummy device and domoticz_main script.Melotron wrote:Can you add Telldus live support this way, or do I need to have a usb stick ?
Regards Magnus Svensson
You just need tdtool.py:
http://developer.telldus.se/attachment/ ... sensors.py
That works just like the "tdtool" command, but uses Live server instead. You don't need to install telldusd or any other software, just this one python script. Run it once to get authentication credentials, it stores them to tdtool.conf.
Here is my script.. It is based on some script I found on this forum. It caches switch id's to /tmp/telldus.lst. The file is recreated if switch id is not found, for example if you have just added new one. You must use same switch name in domoticz and Telldus Live.
Code: Select all
#!/bin/bash
startup_path=$1
hardware_id=$2
device_id=$3
status=$4
status2=$5
devname=$6
LOGFILE=/dev/null
echo "startup_path=${startup_path}, hardware_id=${hardware_id}, device_id=${device_id}, status=${status}, status2=${status2}, devname=${devname}" >>$LOGFILE
# Tellstick Hardware has hardware_id=5
if [ "${hardware_id}" = "5" ] ; then
# tdtool commands are always lowercase whereas Domoticz uses mixed case for status. tdcmd is either "on" or "off" after this
tdcmd=${status2,,}
# if command is to dim device we need to find dimlevel and set that
# Domoticz uses the status "Set Level: [n] %" where n is the dimlevel to use
tmp="${tdcmd%:*}"
if [ "$tmp" = "set level" ] ; then
# Get percentage which is found between : and %
tmp="${tdcmd#*:}"
dimlevel="${tmp//%/}"
# Tellstick dim level are 0-255 so we need to convert percentage
dimlevel=$((dimlevel*255/100))
# Set tdtool command to use
tdcmd="dim"
fi
# get device id from name
telldus_id=`grep -w "$devname" /tmp/telldus.lst | cut -f1`
if [ 0$telldus_id -eq 0 ]; then
/home/pi/SMA-EM/tdtool.py --list >/tmp/telldus.lst
telldus_id=`grep -w "$devname" /tmp/telldus.lst | cut -f1`
fi
# Execute Tellstick command
# We need both command and devname set to execute tdtool
if [ "${tdcmd}" != "" ] && [ "${tdcmd}" != "" ] ; then
if [ "${tdcmd}" = "dim" ] ; then
echo "Setting dim level for" $devname "to" $dimlevel >>$LOGFILE
/home/pi/SMA-EM/tdtool.py --dimlevel $dimlevel --dim "$telldus_id" >>$LOGFILE
else
echo "Changing" "$devname" "to" $tdcmd >>$LOGFILE
/home/pi/SMA-EM/tdtool.py --$tdcmd "$telldus_id" >>$LOGFILE
fi
fi
fi
# End of Tellstick section